Cases/Set object to take coordinates of Print Range
Well, you would of thought that would be the end of this
problem. However......
Printthisrange still refused to work with this approach
so..... I got some more help and I have gotten a little
farther with the following procedure.
Private Sub btnprint1_Click()
Dim Printthisrange
Select Case True
Case OptCNGOBA.Value
Set Printthisrange = Range("OBACGG")
Case OptDEFSOBA.Value
Set Printthisrange = Range("OBADEFS")
Case OptAgaveOBA.Value
Set Printthisrange = Range("OBAAgave")
Case OptTWMLOBA.Value
Set Printthisrange = Range("OBATWML")
This way it tests for a true value on the option button,
and then it actually set the printrange like it was
supposed to.
The rest of the procedure is what I'm experimenting with
right now. I can get it to print preview the range, but I
am having trouble with the fact that each range is on a
separate sheet, and I need to select either the range or
the worksheet so I can do a with statement for the
formatting. For some reason, the statement
"Printthisrange.select" sometimes refuses to select as I
select it when testing it with each option. It just gives
me this run time error '1004': and then the next line of
the box says "Select method of Range class failed"
Maybe I have to hold my tongue a certain way perhaps for
this to work on each time?
This is the full procedure as I have it now:
Private Sub btnprint1_Click()
Dim Printthisrange
Select Case True
Case OptCNGOBA.Value
Set Printthisrange = Range("OBACGG")
Case OptDEFSOBA.Value
Set Printthisrange = Range("OBADEFS")
Case OptAgaveOBA.Value
Set Printthisrange = Range("OBAAgave")
Case OptTWMLOBA.Value
Set Printthisrange = Range("OBATWML")
End Select
Printthisrange.Select
'With Worksheets(Printthisrange.Parent.bane).PageSetup
' .PrintTitleRows = ""
' .PaperSize = xlPaperLegal
' .FitToPagesWide = 1
' .FitToPagesTall = 1
' .Orientation = xlLandscape
'End With
Unload Me
Printthisrange.PrintPreview
Printthisrange = "Nothing"
Range("a1").Select
End Sub
|