PDA

View Full Version : [SOLVED] Excel 2010-Run VBA code pressing a sheet button



Victor
07-04-2010, 05:04 AM
I get this error each time i try to run the vba code below pressing a sheet botton in Excel 2010:


Sub ClosedIt()
ActiveWorkbook.Close SaveChanges:=False
End Sub

The error is:


Problem signature:
Problem Event Name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 14.0.4417.1000
Application Timestamp: 4a8efbb9
Fault Module Name: EXCEL.EXE
Fault Module Version: 14.0.4417.1000
Fault Module Timestamp: 4a8efbb9
Exception Code: c0000005
Exception Offset: 00cc9dfd
OS Version: 6.1.7600.2.0.0.768.3
Locale ID: 1033
Additional information about the problem:
LCID: 1033
skulcid: 1033


In Excel 2007 I have no problems with it.

I attached a sample code to see if you can emulate the problem pressing the sheet botton in Excel 2010.

Thanks for the help you can provide to solve this problem.

Victor

mdmackillop
07-04-2010, 12:28 PM
I get error 400 sometimes. I don't get an error if I move the code to Personal or a standard sub.

Victor
07-05-2010, 04:39 AM
MD:

Thanks.

By a standard sub you mean move the code to a module? Is this is the case I still have the problem, or please give me an example of a standard sub for me code.

Thanks again.

Any other suggestion is welcome.

Victor

mdmackillop
07-05-2010, 05:55 AM
A sample

Victor
07-05-2010, 07:09 AM
MD:

It is interesting how the way you do it works excellent. At first I thought you were calling the code CloseIt using other code, but that do not works.

Maybe I am asking to much but what is the reasoning for doing it the way you suggest, that works?

Is there is a bug in Excel 2010 VB7? I tried googled it for a solution but the only way to do it at this moment is using your recommendation.

Thanks

Victor

mdmackillop
07-05-2010, 07:13 AM
I got an error running it from a Sheet Module so I tried other ways. Not everything makes sense. I don't see a reason for the errors in any method.

Victor
07-05-2010, 07:40 AM
MD:

Excel works in mysterious ways.

Thanks

Victor