Martin_H
Board Regular
- Joined
- Aug 26, 2020
- Messages
- 190
- Office Version
- 365
- Platform
- Windows
Hi team,
down below is the code that runs on WB open.
Every time I open that Workbook I am getting a Run-time error '1004'.
What could be the cause?
Thank you for help.
down below is the code that runs on WB open.
Every time I open that Workbook I am getting a Run-time error '1004'.
What could be the cause?
Thank you for help.
VBA Code:
Private Sub Workbook_Open()
With Application
.ScreenUpdating = False: .WindowState = xlMaximized: .DisplayStatusBar = True
Call OptimizeCode_Begin
Worksheets("WELCOME").Activate
With ActiveWindow
Worksheets("WELCOME").Range("A1:AD1").Select
.DisplayHorizontalScrollBar = False: .DisplayVerticalScrollBar = False: .DisplayWorkbookTabs = False: .ZOOM = True: .ScrollRow = 1: .ScrollColumn = 1
Worksheets("WELCOME").Range("A1").Select
End With
Call OptimizeCode_End
.ScreenUpdating = True
End With
End Sub
VBA Code:
Public CalcState As Long
Public EventState As Boolean
Public PageBreakState As Boolean
Sub OptimizeCode_Begin()
EventState = Application.EnableEvents
Application.EnableEvents = False
CalcState = Application.Calculation
Application.Calculation = xlCalculationManual
Application.DisplayFormulaBar = False
PageBreakState = ActiveSheet.DisplayPageBreaks
ActiveSheet.DisplayPageBreaks = False
End Sub
Sub OptimizeCode_End()
ActiveSheet.DisplayPageBreaks = PageBreakState
With Application
.Calculation = CalcState: .Calculation = xlCalculationAutomatic: .EnableEvents = EventState: .EnableEvents = True
End With
End Sub