View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bruce Roberson Bruce Roberson is offline
external usenet poster
 
Posts: 47
Default Revised btnprint1_click()

yesterday, I posted a similar routine where I was trying
to pass along a control option to a print range, so that I
could print selected reports based on selecting a print
range that was passed along from this procedure.

I was seeking help with that, but I think I've figured out
another route that I still need help with.

I have five options on a frame with the default option
being the print all ranges. Someone suggested before I did
the following cases that the caption in this script had to
be a valid range name, but I didn't want to name them that
way. So, I devised this attempt at using cases to name the
print range based on the caption I listed in these cases.

Where it appears to hang now when I step through it is in
the line: Range(Printthisrange).Select

As far as I could tell, if "Printhisrange" were defined as
a range, then shouldn't I be able to pass along a name to
that variable based on my cases here. And then when the
cases selected the value of "printthisrange", shouldn't I
be able to pass that along to the line listed above?

And then once I've solved that mystery, really what I need
to do is provide for the "Print All OBA Pages" case in
which I need to select all four previous ranges for the
print.

I'm still very much a newbie at Visual Basic, but I think
I'm learning quickly.

Private Sub btnprint1_Click()
Dim myOption As Control
Dim Printoption
Dim Printthisrange As Range
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

For Each myOption In Frame1.Controls
If myOption.Value = True Then
Printoption = myOption.Caption
End If
Next myOption

Select Case Selectprnrange
Case 1
Printoption = "Cantera Natural Gas"
Printthisrange = "OBACGG"
Case 2
Printoption = "DEFS"
Printthisrange = "OBADEFS"
Case 3
Printoption = "Agave"
Printthisrange = "OBAAgave"
Case 4
Printoption = "TWML"
Printthisrange = "OBATWML"
Case 5
Printoption = "Print All OBA Pages"


End Select



Unload Me
Range(Printthisrange).Select
Selection.PrintPreview
Range("a1").Select


End Sub