在后台启动没有excel的userform

问题描述 投票:1回答:1

我有这个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打开。

不知道如何保护文件,没有最终用户改变文件任何想法?

vba userform
1个回答
0
投票

也许这有助于:

在“打开”下的“ThisWorkbook”中添加:

Private Sub Workbook_Open()
    Application.Visible = False
    UserForm2.Show vbModeless
End Sub

这将隐藏Excel并执行UserForm2。

顺便说一句:要结束您的程序,请添加此代码(例如,添加到您的一个Userform按钮):

Private Sub CommandButton1_Click()
    Application.Quit
End Sub

它将关闭Excel。

© www.soinside.com 2019 - 2024. All rights reserved.