要求用户启用宏

时间:2018-10-09 16:11:46

标签: vba excel-vba

我做了一个“欢迎”表,其中说应该启用宏

如果启用了宏,则“欢迎”表将被隐藏, 如果禁用了宏,则所有表格都将被隐藏,除了“欢迎”

这是我的代码,它在打开文件时运行,但是在关闭时会声明错误

我已经将模块安装在ThisWorkbook

Private Sub Workbook_Open()
    Dim Current As Worksheet
    For Each Current In Worksheets
         Current.Visible = xlSheetVisible
    Next Current
    Worksheets("welcome").Visible = xlSheetVeryHidden
    End Sub


'=========   
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim Current As Worksheet
        For Each Current In Worksheets
            If Current.Name <> "welcome" Then
                Current.Visible = xlSheetVeryHidden
            End If
        Next Current
    End Sub

有人可以帮助我确定错误吗?

enter image description here

0 个答案:

没有答案