Excel shuts down when macros enabled due to Workbook_Open event

PIMotion

New Member
Joined
Sep 15, 2009
Messages
4
I have MSOffice 2007 installed with latest patches. Previously, even with
Excel 2000 on same machine this behavior occurred.

Situation: to isolate using the simplest of examples... a blank XLS (97-2003 format) sheet - no formulas or formatting, and no fancy VBA code. VBAProject code exists in just ThisWorkbook.Workbook_Open event. Even if just one lonely comment character exists within the Workbook_Open event, Excel shuts down when macros are enabled. I am using just the Excel installation, no subsequent add-ins or tweaking or templates modified, added, deleted, manipulated. Macro security is set to lowest. Excel option to trust is granted for VBA.

Example setup: Open a new workbook. Go to VBAProject. For the ThisWorkbook object, enter (or after choosing from drop-down):

Private Sub Workbook_Open()
'
End Sub

The comment character within the event could have been a Msgbox or some other code, but can't get much simpler or more harmless than a comment character! Having any non-blank character or characters in the Workbook_Open event causes Excel to shut down when macros are enabled.

However, if the event was empty of code, as follows:

Private Sub Workbook_Open()

End Sub

then no problem - Excel stays open. Doesn't matter if there are other macros within let's say Module1 or some module name. Only when non-blank character within Workbook_Open event will Excel shut down.

A solution is needed for an XLS (97-2003 format) file.

Cannot use Auto_Open subroutine within the VBAProject because the workbook is typically opened and manipulated externally from other applications (such as VB component), and the 'caller' will not be using the RunAutoMacros method.

Would appreciate suggestions regarding cause of problem and remedy. Thanks for consideration!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
This is a bit strange.

Well, few suggestions to be able to identify the problem. Use the following sub:

Private Sub Workbook_Open()
MsgBox "I'm opening"
End Sub

Also make a similar beforeClose Sub with a different message.

Now opening this file with Macros enabled will display massages whose sequance will tell you which event occurred first. This is a must to identify where to look for problems
 
Upvote 0
Thanks for your review and response. Good suggestion about the beforeclose event. Here is the code I inserted into the 'blank' workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "before close. Cancel =" & Cancel
End Sub

Private Sub Workbook_Open()
MsgBox "in Workbook_Open event"
End Sub

Workbook opened. Macro Security was set to disable with notification. When I 'enabled this content', neither event fired (no msgs executed). Excel shut down with error. Application event log indicates faulting module unknown. Here is the log entry:

Faulting application excel.exe, version 12.0.4518.1014, stamp 45428263, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x0020566c.
 
Upvote 0
One thing you might want to check is the Auto_Open event in the "Thisworkbook" code. This is equivalent to the workbook_open event.

If you did not find any error source in there, and considering the errors mentioned, I suggest that you re install the office program.



Thanks for your review and response. Good suggestion about the beforeclose event. Here is the code I inserted into the 'blank' workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "before close. Cancel =" & Cancel
End Sub

Private Sub Workbook_Open()
MsgBox "in Workbook_Open event"
End Sub

Workbook opened. Macro Security was set to disable with notification. When I 'enabled this content', neither event fired (no msgs executed). Excel shut down with error. Application event log indicates faulting module unknown. Here is the log entry:

Faulting application excel.exe, version 12.0.4518.1014, stamp 45428263, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x0020566c.
 
Upvote 0
Thanks for your continued support of this issue. The Auto_Open executes automatically only when Excel is launched manually. The Auto_Open is not executed automatically by Excel when the application and subsequently target workbook is opened via code (such as via VB). The 'caller' code would need to explicitly instruct Excel to execute the Auto_Open macro using object.RunAutoMacros xlAutoOpen. Unfortunately that is not a workable solution because the target workbook is typically accessed and processed by 'caller' code (i.e., VB app), and due to development restriction the caller cannot be modified (to use the RunAutoMacros method).

There are definitely no source errors in the workbook. Testing the behavior using a 'blank' workbook with only the Workbook_Open event code in the VBAProject. Even having just a comment character within the event (and no other code, such as Msgbox, etc.) causes Excel to shut down when macros are enabled.

Already have uninstalled, scrubbed registry, and re-installed MSO 2007. Same problem behavior is observed.

Any other suggestions welcome. Thanks again for taking the time to offer assistance.
 
Upvote 0
Turns out this problem behavior was resolved when the afflicted server's OU policy was updated to exclude Excel. Or something along those lines. Case closed! :)
 
Upvote 0
Turns out this problem behavior was resolved when the afflicted server's OU policy was updated to exclude Excel. Or something along those lines. Case closed! :)

Have you got more information. I have the same problem with Excel. Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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