Excel closes when Macros are Enabled

03856me

Active Member
Joined
Apr 4, 2008
Messages
297
I have workbooks that contain 100's of timesheets. The workbooks (20-30) all reside in the same folder. The payroll managers runs another report to pull the summary details from all the workbooks in the folder. 99% of the time there are no issues, but that 1% is causing the entire payroll upload from executing correctly. The problem is the same same code resides in all the workbooks. I have narrowed the issues down to the workbook_open event below. Suggestions on how to modify this code would be welcomed.

VBA Code:
Private Sub Workbook_Open()         'this code prevents duplicate file names in the Project Window
    Application.DisplayAlerts = False
    Application.EnableEvents = True
    Application.Calculation = xlCalculationAutomatic

    Workbooks.Open ThisWorkbook.FullName
    ThisWorkbook.Close False
    Set Application.ThisWorkbook = Nothing
    Application.DisplayAlerts = True
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
If the provided code is all there is within the workbook open event handler, delete the handler in its entirety.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,718
Members
448,986
Latest member
andreguerra

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