J
JCIrish
In the following code grpRows refers to a custom form with a frame containing
three option buttons. Each option button corresponds to a custom view. The
code works when either of the first two option buttons is chosen on the Print
command button of the form. If the third option button is chosen the code
fails and I get the message “â€Run Time error 5. Invalid procedure call or
argument.†The first two custom views are on sheet 1 of the workbook while
the third custom view is on sheet 4 . What am I doing wrong here and how do
I correct this? Any help greatly appreciated.
Private Sub btnPrint_Click()
Dim myControl As Control
Dim myView
For Each myControl In grpRows.Controls
If myControl.Value = True Then
myView = myControl.Caption
Debug.Print myView
End If
Next myControl
ShowView myView
Unload Me
MsgBox "Printing"
End Sub
Sub ShowView(ViewName)
'
ActiveWorkbook.CustomViews(ViewName).Show
End Sub
three option buttons. Each option button corresponds to a custom view. The
code works when either of the first two option buttons is chosen on the Print
command button of the form. If the third option button is chosen the code
fails and I get the message “â€Run Time error 5. Invalid procedure call or
argument.†The first two custom views are on sheet 1 of the workbook while
the third custom view is on sheet 4 . What am I doing wrong here and how do
I correct this? Any help greatly appreciated.
Private Sub btnPrint_Click()
Dim myControl As Control
Dim myView
For Each myControl In grpRows.Controls
If myControl.Value = True Then
myView = myControl.Caption
Debug.Print myView
End If
Next myControl
ShowView myView
Unload Me
MsgBox "Printing"
End Sub
Sub ShowView(ViewName)
'
ActiveWorkbook.CustomViews(ViewName).Show
End Sub