我有这个vba代码,它有一个userform。 现在我想启动userform;人们无法看到工作表的地方。
我在我的代码中添加了这个:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.Visible = True
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True End Sub
然后在" ThisWorkbook;我添加了这个:
Private Sub Workbook_Open()
Application.Visible = False ' only for final version
UserForm1.Show
'enter code here
End Sub
当我将这个.xlsm上传到网站时,以及当你打开它时;它不会立即启动用户窗体。它以某种方式出错。如果你有一个excel打开。
不确定如何保护文件,而不让最终用户更改文件 有任何想法吗?
答案 0 :(得分:0)
也许这会有所帮助:
In" ThisWorkbook"在"打开"添加:
Private Sub Workbook_Open()
Application.Visible = False
UserForm2.Show vbModeless
End Sub
这将隐藏Excel并执行UserForm2。
BTW:要结束您的程序,请添加此代码(例如,添加到您的一个Userform按钮):
Private Sub CommandButton1_Click()
Application.Quit
End Sub
它将关闭Excel。