【发布时间】:2018-10-24 20:43:52
【问题描述】:
场景
我有一个用户表单,使用以下Application.Visible = False 方法打开时将隐藏 excel 工作簿。这些是代码
我的用户表单
show excel 按钮是 Commandbutton1hide excel 按钮是 Commandbutton2
本工作簿
代码
Private Sub Workbook_Open()
Call hideExcel
UserForm1.Show
End Sub
用户表单1
代码
Private Sub CommandButton1_Click()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = True
Else
Application.Visible = True
End If
End Sub
Private Sub CommandButton2_Click()
Call hideExcel
End Sub
Sub UserForm_Initialize()
Call hideExcel
End Sub
Private Sub UserForm_Terminate()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = True
Else
Application.Visible = True
End If
End Sub
Sub userform_click()
Call hideExcel
End Sub
模块
代码
Sub hideExcel()
If Workbooks.Count > 1 Then
Windows(ThisWorkbook.Name).Visible = False
Else
Application.Visible = False
End If
End Sub
问题
我面临的问题是
- 打开我的宏并激活用户窗体。让我们将此文件称为
A - 然后打开另一个工作簿。让我们将此文件称为
B - 试图在工作簿
A隐藏时关闭文件B。但是也会提示关闭文件A,最终所有的excel都将关闭,包括我的宏文件A。
有人知道这里有什么问题吗?
【问题讨论】: