Problems running macro VBA

guido124

New Member
Joined
Jul 27, 2005
Messages
36
I have the following problem:

I received an Excel file with VBA macro. It runs when pressing the macro button. When I save the file, close it and re-open, it crashes when pressing the macro button. If I then close, re-open and now first save (before running the macro), I can run the macro successfully.

The colleague who wrote the macro, can run it under all circumstances. With other colleagues, for some it works, for others it doesn't.

Does anybody know what could cause this?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
1. We'll probably need to see the code to help.
2. Describe "Crashes". What exactly happens? Does it give an error? What error? Do you have a Debug Option when it errors? What line is highlighted...

3. Without knowing the above information, Best guess is a Difference in Excel Versions between you and your coleague(s).
 
Upvote 0
Without having seen any code, the line the code erros on, or the error message the possiblities are endless.
 
Upvote 0
crash:
Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience.

AppName: excel.exe AppVer: 11.0.8146.0 AppStamp:46a45966
ModName: unknown ModVer: 0.0.0.0 ModStamp:00000000
fDebug: 0 Offset: 00000000

Automation Error Exception occurred.

Automation error (Error 440)
 
Upvote 0
Are your Windows/Excel Versions the Same umong all users?


Try this, don't run the macro from the button...

Open the VBE Window (ALT + F11)

find the macro and put cursor at the beginning of that macro.
Press F8 - This will step through the macro 1 line at a time. Make note of which line causes the Crash..

Again, would be helpful to see the code...
 
Upvote 0
When stepping through the code in the debugger (with F8), it simply runs through without any problems.
 
Upvote 0
One more time...to Quote Jerry McGuire...

"Help Me Help You!!!"

Can you show us the code please??


How are you starting the macro, from Tools - Macro - Macros...or with a shortcut key?
 
Upvote 0
I am having this exact same problem. I get the same error message. Here are the steps that recreate the error in my workbook.

I open excel and enable macros. My macro automatically runs and opens a userform. When I close the userform the following code runs

Application.ActiveWorkbook.Save
If Application.Workbooks.count > 1 Then
ActiveWorkbook.Close
Application.DisplayAlerts = False
Else
Application.Quit
Application.DisplayAlerts = False
End If

Excel then closes. When I reopen the file I get the exact error mentioned in the previous posts.

If I comment out the Application.ActiveWorkbook.Save line I do not get the error. What is it about saving that causes this problem and how can I fix this?

Any help you can provide will be greatly appreciated.

Thanks so much.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,952
Members
448,535
Latest member
alrossman

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