View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bruce Roberson Bruce Roberson is offline
external usenet poster
 
Posts: 47
Default Cases/Set object to take coordinates of Print Range

I'm staring over with this post, and see if I can explain
it another way.

This procedure is taking a user choice from an option
button and attempting to assign a predefined print range
from the choice a user selects from one of five option
buttons.

I do know from stepping through this procedure that the
object printoption is taking on a value from the
line "printoption = myoption.caption" as shown below.
However, when it gets down to the cases, and attempts to
set the object "Printthisrange", it apparently isn't
happening like it should.

Therefore, when the procedure gets down to the
line "Printthisrange.select", it acts as if Printthisrange
was never populated, which it wasn't according to the
debug watch I put on this range.

I have played with it and Steve Bell has tried to help,
but it still doesn't work, so I just thought it might help
if I posted all I know about what is happening and what is
not happening.

Hope this help so someone can diagnose the problem I am
having.

__________________________________________________ _________


Private Sub btnprint1_Click()
Dim myOption As Control
Dim Printoption
Dim Printthisrange As Range

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

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


End Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Printthisrange.Select
Unload Me
Selection.PrintPreview
Set Printthisrange = Nothing
Range("a1").Select


End Sub