PDA

View Full Version : [SOLVED] Call Program problem



austenr
11-10-2004, 01:10 PM
This code is at the end of a routine that executes before close. I want to display the user form and then call the routine that the user can choose to execute several choices. When I try to compile the code, I get a message that says "OptionButton1 not defined". Do I have to define it again? It is defined of course in the User Form.


If RngStr <> "" Then
MsgBox Prompt & RngStr, vbCritical, "Incomplete Data"
Cancel = True
Else
UserForm2.Show
Call CommandButton1_Click
Cancel = False
End If

Here is the code for the User Form:


Private Sub CommandButton1_Click()
If OptionButton1 = True Then
MsgBox "Saving Workbook"
ActiveWorkbook.Save
Unload Me
End If
If OptionButton2 = True Then
MsgBox " Saving and Printing All Active Worksheets..."
ActiveWorkbook.Save
Sheets.PrintOut
Unload Me
End If
End Sub

Zack Barresse
11-10-2004, 02:34 PM
Hi Austen,

Have you tried adding .Value after your OptionButton?

Jacob Hilderbrand
11-10-2004, 03:10 PM
Can you attach the workbook for us to have a closer look at?

austenr
11-10-2004, 03:21 PM
Here is the Workbook

Jacob Hilderbrand
11-10-2004, 03:35 PM
Put the code for


Public Sub CommandButton1_Click()

in the User Form code section, not the ThisWorkbook code section.

austenr
11-10-2004, 04:49 PM
Hey thanks...Works great!!

Zack Barresse
11-10-2004, 05:39 PM
Glad to hear it Austen! :yes

I'll mark the thread as Solved then.

Jacob Hilderbrand
11-10-2004, 05:59 PM
You're Welcome

Take Care