如何在vba excel中只显示userform?
我有一个在VB中创build的用户窗体,我想只显示用户窗体,当我打开我的Excel …有没有办法做到这一点..我已经尝试了代码,如
application.visible = false , activewindow.visible= false
如果我在模块中使用这个代码之前,打开已打开的文件将被隐藏与我正在打开的文件可以有人打电话给我我怎样才能特别隐藏我想打开的文件,并显示用户窗体
尝试这样的事情
1-用2个button创build一个用户表格(见下图)
2- ThisWorkbook代码
Private Sub Workbook_Open() UserForm1.Show vbModeless End Sub
3-表格代码
Private Sub CommandButton1_Click() If Workbooks.Count > 1 Then Windows("Test.xlsm").Visible = True Else Application.Visible = True End If End Sub Private Sub CommandButton2_Click() If Workbooks.Count > 1 Then Windows("Test.xlsm").Visible = False Else Application.Visible = False End If End Sub Private Sub UserForm_Initialize() If Workbooks.Count > 1 Then Windows("Test.xlsm").Visible = False Else Application.Visible = False End If End Sub Private Sub UserForm_Terminate() If Workbooks.Count > 1 Then Windows("Test.xlsm").Visible = True Else Application.Visible = True End If End Sub
这只会显示或隐藏表单的工作簿。 任何其他工作簿将不受影响。