Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Help:option buttons custom views and Private Sub btnPrint_Click

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Help:option buttons custom views and Private Sub btnPrint_Click

Must be a problem with the button caption, and the view name. What is it?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JCIrish" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Help:option buttons custom views and Private Sub btnPrint_Clic

The button caption and the view name are the same,"Credit Card Summary YTD"

"Bob Phillips" wrote:

Must be a problem with the button caption, and the view name. What is it?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JCIrish" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Help:option buttons custom views and Private Sub btnPrint_Clic

Thanks, Bob. I checked that a zillion times and was baffled because they were
both the same. I just went back and cleared everything out of the caption and
reentered and it now works. Must have been an extraneous character that I
couldn't spot somewhere in there. Thanks for causing me to go back and do
what I did.

"Bob Phillips" wrote:

Must be a problem with the button caption, and the view name. What is it?

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JCIrish" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
XL 2007 Custom Views - Print Settings Option LPS Excel Discussion (Misc queries) 3 March 3rd 10 03:37 PM
Option Private Module RB Smissaert Excel Programming 5 April 4th 06 04:53 PM
Option Private Module not preventing cross project referencing seisman Excel Programming 2 July 29th 05 03:24 PM
Navigating between option buttons is not selecting the option Gixxer_J_97[_2_] Excel Programming 4 June 2nd 05 02:50 PM
custom toolbar buttons are saved where? Excel loads twice bymistake and all my custom toolbar buttons get gone!!! Kevin Waite Excel Programming 2 March 3rd 04 03:31 PM


All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"