我写的程序:
出现run-tim error‘1004’ select method of worksheet class failed; 还有Object variable or with block variable not set。。。在线求解啊。
Private Sub workbook_open()
Dim ws As Worksheet
Application.ScreenUpdating = False
MsgBox ("Welcome to DFDS Ropax Painting Status Updates!" & vbNewLine & "Press OK to continue.")
Sheets("Main Menu").Select
Range("b2").Select
For Each ws In ThisWorkbook.Worksheets
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.DisplayHeadings = False
Select Case ws.Name
Case "Main Menu"
ws.Visible = xlSheetVisible
ws.Protect Password:="osmarkee", UserInterfaceOnly:=True, AllowFiltering:=True
ws.EnableSelection = xlUnlockedCells
Case "Paint_Blk", "Paint_Tanks", "Paint_Erec"
ws.Visible = xlVeryHidden
ws.Protect Password:="osmarkee", UserInterfaceOnly:=True, AllowFiltering:=True
ws.EnableSelection = xlUnlockedCells
Case Else
ws.Visible = xlVeryHidden
'ws.Visible = True
ws.Protect Password:="osmarkee", UserInterfaceOnly:=True
ws.EnableSelection = xlUnlockedCells
End Select
Next ws
Sheets("Main Menu").Select
Range("b2").Select
MsgBox ("Paint Status Ready for Updates" & vbNewLine & vbNewLine & "Press OK to continue.")
Application.ScreenUpdating = True
End Sub
|