Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel vba隐藏我的工作簿窗口,如何在保存前将其取消隐藏_Excel_Vba_Window_Hide - Fatal编程技术网

Excel vba隐藏我的工作簿窗口,如何在保存前将其取消隐藏

Excel vba隐藏我的工作簿窗口,如何在保存前将其取消隐藏,excel,vba,window,hide,Excel,Vba,Window,Hide,我复制并编辑了在这个问题中找到的一些代码: 尽管代码确实取消/保护了工作表(仍然是一项正在进行的工作,最终将是一个切换),但当我稍后打开工作簿时,工作簿窗口被隐藏,我必须手动按下“查看”功能区中的“取消隐藏窗口”图标。我在代码中看不到任何触发“隐藏”的内容。有人知道如何预防/解决这个问题吗 我的版本: Sub fAMWToggleProtection() Const fPath As String = "S:\SHARED\Cidmls\MasterMix Section\C

我复制并编辑了在这个问题中找到的一些代码:

尽管代码确实取消/保护了工作表(仍然是一项正在进行的工作,最终将是一个切换),但当我稍后打开工作簿时,工作簿窗口被隐藏,我必须手动按下“查看”功能区中的“取消隐藏窗口”图标。我在代码中看不到任何触发“隐藏”的内容。有人知道如何预防/解决这个问题吗

我的版本:

    Sub fAMWToggleProtection()

    Const fPath As String = "S:\SHARED\Cidmls\MasterMix Section\Copy of Master Mix templates for testing\"
    Dim sh As Worksheet
    Dim sName As String

    With Application
        .EnableEvents = False
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With

    sName = Dir(fPath & "*.xls*")

    Do Until sName = ""
        With GetObject(fPath & sName)
            For Each sh In .Worksheets
                With sh
                    .Visible = True
                    .Unprotect Password:="icpmr"
'                    .Protect Password:="icpmr"
                End With
            Next sh
'            .Save
'            .Close True

        Debug.Print sName

        End With
        sName = Dir
    Loop

    With Application
        .EnableEvents = True
        .ScreenUpdating = True
        .DisplayAlerts = True
    End With

    MsgBox "Complete", vbOKOnly, "Uprotect all sheets"

    On Error GoTo 0
    Exit Sub

fAMWToggleProtection_Error:
        MsgBox "Error " & Err.Number & " (" & Err.Description & ") in fAMWToggleProtection of Module1"

End Sub
尝试:

使用GetObject(fPath和sName)的


.Windows(1).Visible=True“我花了很长时间来解决为什么这对我不起作用。最后我意识到我没有在开始时添加句点!谢谢:-)
    With GetObject(fPath & sName)
        .Windows(1).Visible = True ' <-- Not tested, but assuming this is a Workbook object
        For Each sh In .Worksheets