[VBA] Excel How to hide the main window

[VBA] Excel How to hide the main window


We can use to hide the main window approach requires the user to enter the account password, as shown below

Snapshot -200,963,018,125

From the above chart that Excel has been carried out, but the main application window is hiding.

1. hidden way is very simple as long as the property can be set Application.Visible = True

Or 2. using the following property, out of the main screen window
Application.WindowState = xlNormal
Application.Left = 10000

How to hide the main window Excel

1. Use Workbook_Open event, make Excel a hidden executed after the main program screen

 Private Sub Workbook_Open()
'活页簿开启时即隐藏Excel
Application.Visible = False
'秀出登入画面
UserForm1.Show
End Sub

2. Add the success of the program to determine whether to sign

Private Sub Login_Click()
If UserName = "余小章" And UserPassword = "ggyy" Then
Unload Me
'登入成功后显示EXCEL
Application.Visible = True
Else
MsgBox "使用者名称或密码错误!", vbCritical, "错误"
End If
End Sub

Private Sub Cancel_Click()
Unload Me
'关闭应用程序
Application.Quit
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'判断是否按X关闭
If CloseMode <> 1 Then
Cancel = True
'关闭应用程序
Application.Quit
End If
End Sub
3.范例下载:如何隐藏主窗口.rar

PS. Do not forget security settings Execl can execute this example!

Snapshot -200,963,018,425

Snapshot -200,963,018,433

If any error, please notify the novice posting him to bear

2010 ~ 2017 C # in the fourth quarter

Original: Large columns  [VBA] Excel How to hide the main window


Guess you like

Origin www.cnblogs.com/petewell/p/11495873.html