PDA

View Full Version : [SOLVED] Animation Error



austenr
11-08-2004, 01:10 PM
I am running ECXEL 97 abd get the following error when I execute the code below:

Animation type not supported in Visual Basic


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As VbMsgBoxResult
If OptionButton1 = True Then
Msg = MsgBox("Saving Workbook", vbInformation, "Saving...")
ActiveWorkbook.Save
Unload Me
End If
If OptionButton2 = True Then
ActiveWorkbook.Save
Sheets.PrintOut
Unload Me
End If
End Sub


Thanks in advance for your help

austenr
11-08-2004, 01:26 PM
Oops...I meant Automation Error..Can't type today

CBrine
11-08-2004, 01:36 PM
austenr,
I'm not sure of this, but thought I would give it a shot.

You are using the Unload Me, to unload a form, in the worksheet before close event. The workbook event most likely cannot resolve what me represents? Try changing it to
Userform1.unload

HTH
Cal

austenr
11-08-2004, 02:11 PM
No that didn't work...All I am trying to do is unload the form after the user either makes a selection of Save or Print and Save the workbook..Any suggestions? Thanks

CBrine
11-08-2004, 02:17 PM
Are you printing from a userform button? Or are you using a modeless form?

mdmackillop
11-08-2004, 02:34 PM
Hi Austen,
I've enclosed an xlfile which may suit your purpose. The WorkBookClose event opens the UserForm with the Save and Print/Save options. or the button opens the form for "normal" use.
MD

austenr
11-08-2004, 02:42 PM
No that did not run...I get an Automation error on the first line :

Msg As VbMsgBoxResult

Compile error..Automation type not supported in Visual Basic....

austenr
11-08-2004, 02:43 PM
Sorry...This is a Dim Statement

mdmackillop
11-08-2004, 02:46 PM
I was just about to Edit. You don't require the Dim line with this message box. Delete the Msg as ... line and just use

MsgBox "Saving Workbook", vbInformation, "Saving..."

Zack Barresse
11-08-2004, 03:09 PM
And btw, if you are only using ", vbInformation," as your msgbox type, you will only have (by default) an OkOnly type of msgbox, unless otherwise specified. So if that were the case, there would be no reason to dim a MsgBoxResult. Just fyi.

Jacob Hilderbrand
11-08-2004, 03:38 PM
Maybe VbMsgBoxResult is not supported in 97. You can always use the Long Data Type if needed.

Dim Msg As Long

austenr
11-08-2004, 04:38 PM
thanks everyone...this one is solved

Zack Barresse
11-08-2004, 05:16 PM
thanks everyone...this one is solved

Great! Do you know how to Mark it so? Take a look

...