我在Workbook模块中有以下代码:
Private Sub Workbook_Open()
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.DisplayHeadings = False
Application.WindowState = xlMaximized
ActiveSheet.UsedRange.Select
ActiveWindow.Zoom = True
Range("A1").Select
End Sub
但是当我打开相关工作簿时,代码中的设置也会应用于所有其他打开的工作簿。如何限制代码中的设置以仅应用于相关工作簿? 最诚挚的问候
编辑: 这个解决方案对我来说也不起作用:
Private Sub Workbook_Open()
With Me
Application.WindowState = xlMaximized
ActiveSheet.UsedRange.Select
ActiveWindow.Zoom = True
Range("A1").Select
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
Application.DisplayFormulaBar = False
Application.DisplayStatusBar = Not Application.DisplayStatusBar
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.DisplayHeadings = False
End With
End Sub
答案 0 :(得分:0)
试试这个,在With me
之后的行中添加Private Sub Workbook_Open()
Private Sub Workbook_Open()
with me
'all the rest of the code
end with
end sub
它在这里工作