0

I have an Excel workbook that causes an error when it is started on a particular PC. No other workbooks give the same error on this PC, and the workbook itself causes no problems on any other PC. The error is:

 Microsoft Visual Basic for Applications

      This action will reset your project, proceed anyway?

It makes no difference which button is then clicked, the error just loops, and the only way I have found to break out of it is to use the Task Manager to end the Excel application.

The workbook is 'trusted' and macros are started automatically. If I switch this off then the file can be opened, but as soon as macros are enabled the error occurs as before.

So far I have tried de-activating all add-ins one by one, and varying the trust levels, but cannot open the workbook with macros enabled.

It is obviously the combination of the workbook and the PC that is the problem, and I suspect that it is some setting within the Excel application on the PC that is to blame. Does anyone have any ideas?

Thanks, Kevin

6
  • Try declaring option explicit in the code, then try opening it. Feb 10, 2015 at 16:13
  • Just tried that but it makes no difference. I also should have mentioned earlier that once the error box appears I cannot 'break' into the VBE. Feb 10, 2015 at 16:31
  • I only ever see that message when I run code, it throws an error, and I start editing the code. If I change certain things, it gives that warning to say it's going to kick me out of debug mode and stop the code altogether. I could only see that happening automatically if there's an autoexec macro running that tries to change code and the user has allowed access to VBA. In Excel 2010, that's File > Option > Trust Center > Trust Center Settings > Macro Settings > Trust access to the VBA project object model Feb 10, 2015 at 16:35
  • To debug, try this: Open some other workbook. Write a little code with a stop built in (F9) and run it. Now you're in debug mode, stopped on that line. Go open the troublesome file. Any macros that fire automatically won't this time because you're in debug mode. Go look for the problem / add stops in that code / do whatever to debug. Feb 10, 2015 at 16:36
  • Thanks - tried this. I opened a new workbook, created and ran a macro that just had a Stop, and then opened the problem workbook without the error condition. Great! But in the debugger there is absolutely no indication of any problem. So I saved the workbook and tried opening it again on its own and the error is back. Feb 10, 2015 at 16:51

1 Answer 1

0

I ran some more tests to try and isolate the error - the one that gave the clue was to log on to the problem PC as a different user and then try to open the workbook. This did not give the error condition, so I concluded that the problem only existed for a particular user on a particular machine, and hence the solution most likely lay in the Registry.

So I edited the registry and (logged in as the problem user, and after making backups) I first deleted the key

HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel

and then re-opened the workbook. This made no difference, so I next deleted the key

HKEY_CURRENT_USER\Software\Microsoft\VBA

This time I opened the workbook without any errors.

So I must have unwittingly changed some setting in VBA that caused the problem - I still don't know what exactly - but by deleting the Registry Key and restarting Excel I have effectively reset VBA back to its default settings. I have lost other settings that I have made, but these can be re-made and I can now open the workbook.

It would be nice to know how the error actually arose, but you can't have everything.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .