Excel Workbook Won't open - Gets error!!

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hi all,

I'm not sure what I did, but I can't get my excel workbook to open properly, and I get this error.
Run Time error 1004
Method 'worksheets' of object '_Global' failed

I am able to open and unlock VBA, but I can't seem to make anything work.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Do you get a popup with the option to debug?
 
Upvote 0
That indicates there's something wrong with the code in ThisWorkbook / Sub Workbook_Open, or in code that's called by this Sub.

Save the Workbook with VBA unlocked, and when you re-open and get the error, you should be able to go into Debug mode and see which line is causing the problem.

Post your code if you can't work out why it's erroring.
 
Upvote 0
I run my workbook open sub and it runs until it gets to this:

Code:
Private Sub NextOpen()Dim ws As Worksheet
Application.OnKey "{F2}", "module5.pophelp"
Application.OnKey "{F4}", "module5.XAB"
Application.DisplayFormulaBar = False
Application.CellDragAndDrop = False
Application.CommandBars("Shapes").Enabled = False
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)"
[COLOR=#ff0000] For Each ws In Worksheets[/COLOR]
    ws.Activate
    With ActiveWindow
        .DisplayHeadings = False
        .DisplayGridlines = False
    End With
Next ws
Then the red line is highlighted and I get the same error as before.
Excel is just a gray screen with no functionality other than close/minimize window
 
Upvote 0
Also should add that when I try to close now
Code:
ActiveWorkbook.Unprotect
gets flagged with error Run-Time error 91:


It's like my sheet is open, but VB can't find it so it throws errors as if I'm trying to do stuff on a workbook that's not open.
 
Upvote 0
Where is the Workbook_Open() event routine in your post ?!
 
Last edited:
Upvote 0
Code:
Private Sub Workbook_Open()Application.DisplayAlerts = False
If Sheets("Home").Range("AK1").Value = 1 Then
    Application.Run "module5.destructure"
    Sheets("Home").Visible = True
    Sheets("Home").Select
    Sheets("Home").Range("AK1").Value = "Open Code"
    
    Application.Run "Module1.HideAllExceptScheduler"
    Application.Run "module5.structure"
    'Application.DisplayAlerts = True
Else
    'MsgBox "preopen is running"
    
    
    
    
    'Application.ScreenUpdating = False
    'ActiveWindow.Visible = False
    'SplashUserForm.Show
    'Windows(ThisWorkbook.Name).Visible = True
    'Application.ScreenUpdating = True
    'MsgBox "premod13"
    Application.Run "Module13.PreOpen"
End If


End Sub
Sorry, it calls that function
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top