chriscorpion786
Board Regular
- Joined
- Apr 3, 2011
- Messages
- 112
- Office Version
- 365
- Platform
- Windows
Hi All,
I have a macro file that has Workbook open code that minimizes the ribbon and hides a sheet along with hiding the formula bar....
To check the file if its working correctly as I would like to distribute it to my colleagues, I sent it to my other laptop through email and when I opened it up on the other laptop downloaded from the internet, it gives me a "run time error'91' object variable or with block variable not set". Another error it throws up is " Run time-error 1004, Method sheets of object' Global failed".
Any solution and idea what could be causing this. When the same file is opened on the source laptop where I created it, it works absolutely fine without any errors.
Private Sub Workbook_Open()
With ActiveSheet
.Unprotect Password:="VBA"
With ActiveWindow
' .DisplayHorizontalScrollBar = False
' .DisplayVerticalScrollBar = False
End With
With Application
.DisplayFullScreen = True
.DisplayFormulaBar = False
.DisplayStatusBar = False
.ActiveWindow.DisplayHeadings = False
End With
With Application
.CommandBars("Full Screen").Visible = False
.CommandBars("Worksheet Menu Bar").Enabled = False
.CommandBars("Standard").Visible = False
.CommandBars("Formatting").Visible = False
End With
ActiveWindow.Zoom = 80
Sheets("Controls").Visible = xlVeryHidden
Sheets("CALENDAR").Activate
Range("N2").Value = Environ("Username")
Protectsheet
End With
End Sub
********************************
Sub Protectsheet()
ActiveSheet.Protect Password:="VBA"
Exit Sub
End Sub
I have a macro file that has Workbook open code that minimizes the ribbon and hides a sheet along with hiding the formula bar....
To check the file if its working correctly as I would like to distribute it to my colleagues, I sent it to my other laptop through email and when I opened it up on the other laptop downloaded from the internet, it gives me a "run time error'91' object variable or with block variable not set". Another error it throws up is " Run time-error 1004, Method sheets of object' Global failed".
Any solution and idea what could be causing this. When the same file is opened on the source laptop where I created it, it works absolutely fine without any errors.
Private Sub Workbook_Open()
With ActiveSheet
.Unprotect Password:="VBA"
With ActiveWindow
' .DisplayHorizontalScrollBar = False
' .DisplayVerticalScrollBar = False
End With
With Application
.DisplayFullScreen = True
.DisplayFormulaBar = False
.DisplayStatusBar = False
.ActiveWindow.DisplayHeadings = False
End With
With Application
.CommandBars("Full Screen").Visible = False
.CommandBars("Worksheet Menu Bar").Enabled = False
.CommandBars("Standard").Visible = False
.CommandBars("Formatting").Visible = False
End With
ActiveWindow.Zoom = 80
Sheets("Controls").Visible = xlVeryHidden
Sheets("CALENDAR").Activate
Range("N2").Value = Environ("Username")
Protectsheet
End With
End Sub
********************************
Sub Protectsheet()
ActiveSheet.Protect Password:="VBA"
Exit Sub
End Sub