Hi, hab folgenden code eingegeben. ich drücke nen button, dann öffnet sich ein fenster, jedoch wenn ich "1" eingebe tut sich garnix. eigentlich sollte der pc dann herunterfahren.. wodran könnte das liegen?
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
' Declare API function.
Declare Function ExitWindows Lib "user32" Alias "ExitWindowsEx" _
(ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
Sub Exit_Windows()
Dim result As Variant
' The following line is a placeholder.
begin:
' Display a box that returns a choice number to the variable "result".
result = Application.InputBox("Bitte Wählen" & Chr(13) _
& Chr(13) & "1. Heimfahren" & Chr(13) & _
"2. neustarten")
' Test the variable "result"
Select Case result
' If "result" is 1 execute the ExitWindows function passing it
' the variable for a Shutdown.
Case 1
ExitWindows EWX_SHUTDOWN, &HFFFF
' If "result" is 2 execute the ExitWindows function passing it
' the variable for a Reboot.
Case 2
ActiveWindow.SmallScroll Down:=45
' If "result" is False the Cancel button was chosen on the
' InputBox so it exits the subroutine.
Case False
Exit Sub
' If "result" is anything other than one of the choices above
' the following line displays a message box which either exit the
' subroutine or start at the "begin" line.
Case Else
choice = MsgBox("Wirklich herunterfahren?!" & Chr(13) & _
Chr(13) & " Achtung", vbOKCancel + vbQuestion)
If choice = vbOK Then
GoTo begin
Else
Exit Sub
End If
End Select
End Sub
|