cqy 发表于 2005-5-30 14:17:00

EXCEL的宏运行完后,如何用内部VBA关闭电脑?

WIN2000


EXCEL的宏运行完后,如何用内部VBA关闭电脑?<BR>

mccad 发表于 2005-5-30 21:32:00

' 其中vFlags参数决定用户需要做的关机操作,
' dwReserved参数是作为保留而没有使用。
  Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,ByVal dwReserved As Long) As Long
  Const ShutDown = 1
  Const ReBoot  = 2
  Const LogOff  = 0
       Dim Sh As Long
' 关闭计算机选项
       Sh = ExitWindowsEx(ShutDown, dwReserved)
' 重新启动计算机选项
  Sh = ExitWindowsEx(ReBoot, dwReserved)
' 关闭所有程序并以其他用户身份登录选项
  Sh = ExitWindowsEx(LogOff, dwReserved)

cqy 发表于 2005-5-31 14:55:00

在EXCEL中


Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long<BR>                       Const ShutDown = 1<BR>                       Const ReBoot = 2<BR>                       Const LogOff = 0<BR>                       Dim Sh As Long<BR>Sub Macro1()<BR>                       Sh = ExitWindowsEx(ShutDown, dwReserved)<BR>End Sub


没响应。
页: [1]
查看完整版本: EXCEL的宏运行完后,如何用内部VBA关闭电脑?