when trying to shut down the system
it should display the message before shutdown you need logout
then it should display an userform
after logout the system need to shutdown automatically it is possible to
Please help me how can i do it
it should display the message before shutdown you need logout
then it should display an userform
after logout the system need to shutdown automatically it is possible to
Please help me how can i do it
Code:
Private Sub CommandButton1_Click()Dim irow As Long
Dim ws As Worksheet
Dim info
info = IsWorkBookopen("\\bms\Service log request\login details\workstation.xlsx")
'we open the workbook if it is closed
If info = False Then
Workbooks.Open ("\\bms\Service log request\login details\workstation.xlsx")
End If
Set ws = Worksheets("Logout Time")
'Find first empty row in database
irow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'Check for a Name number
If Trim(Me.txt1.Value) = "" Then
Me.lbl2.SetFocus
End If
'Copy the data to the database
ws.Cells(irow, 1).Value = Me.lbl1.Object
ws.Cells(irow, 2).Value = Me.lbl2.Object
ws.Cells(irow, 3).Value = Me.lbl3.Object
ws.Cells(irow, 4).Value = Me.lbl4.Object
ws.Cells(irow, 5).Value = Me.txt1.Value
ws.Cells(irow, 6).Value = Me.txt2.Value
Me.lbl1.Caption = ""
Me.lbl2.Caption = ""
Me.lbl3.Caption = ""
Me.lbl4.Caption = ""
Me.txt1.Value = ""
Me.txt2.Value = ""
Me.txt1.SetFocus
Application.DisplayAlerts = False
Workbooks("workstation.xlsx").Save
Workbooks("workstation.xlsx").Close
Application.DisplayAlerts = True
MsgBox "You have Logged Out close the file"
Unload Logout
End Sub
Private Sub UserForm_Initialize()
Me.lbl1 = Application.username
Me.lbl3 = Date
Me.lbl4 = Time
Me.lbl2 = Environ$("computername")
End Sub