PDA

View Full Version : Error when closing workbook



circaa
11-08-2006, 01:06 PM
Hi

I have a button on my form that saves and closes the workbook. I did it like that :

Private Sub CommandButton5_Click()
ThisWorkbook.Save
ThisWorkbook.Close
End Sub

But i get an error message when clicked, it's an excel message that says that excel has encountered an error and must close. The code of the error is 0xc0000005. I noticed that i get the error only when i made changes to the sheets of the workbook.

Can you help me out here

Joey

malik641
11-08-2006, 02:48 PM
Hi Joey, welcome to VBAX :hi:

I noticed that i get the error only when i made changes to the sheets of the workbook.What changes? Before you open the form? Or changes the form does for you?

I couldn't replicate your error...do you mind providing all the code your using?

circaa
11-08-2006, 03:04 PM
Maybe i should have mentionned that I use a vbscript to hide excel at the beginning. I show the form

The changes i'm refering to are on charts, the user chooses what he wants to display from the form and then I hide the form and show the chart. When he's done, I hide excel, reshow the form. At that point, if I click my command button that saves and closes, i get the error.

If this doesn't help you ....I'll provide my code

thanks

Joey

Prasad_Joshi
11-10-2006, 02:43 AM
Other copy of Excel may be in the memory. Check Task manager when error occurs.

Prasad

Charlize
11-10-2006, 03:04 AM
Maybe close userform before closing workbook.


sub cmdbutton5_click()
unload me
' maybe make excel visible
application.visible = true
thisworkbook.save
thisworkbook.close
end sub
Charlize