+ Reply to Thread
Results 1 to 2 of 2

Print from Option Buttons

  1. #1

    Print from Option Buttons

    I have a Userform with 3 OptionButtons, allowing the user to decide
    what Range of cells on Worksheet A to print. Ranges are like this:
    OptionButton1: printarea = A3:N53
    OptionButton2: printarea = A60:N112
    OptionButton3: printarea = A3:N112 (fit to 2pages)

    I've included a PRINT button and a CANCEL button on the Form.

    So, three questions:
    ** How do I build the code to print the desired range when the option
    button is selected and the Print button pressed?

    ** Can I make OptionButton1 the default? how?
    ** where do I put the other page formatting info (ie margins and such)
    -- on Worksheet A or with the optionbutton code?

    Thanks very much for your help...
    ray


  2. #2
    Registered User
    Join Date
    06-02-2006
    Posts
    39
    Private Sub cmdPrint_Click()
    If OptionButton1.Value = -1 Then
    With Worksheets("Sheet1").PageSetup

    .PrintArea = "$A$3:$N$53"
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1

    .BottomMargin = Application.InchesToPoints(0.5)
    .TopMargin = Application.InchesToPoints(0.5)
    .LeftMargin = Application.InchesToPoints(0.5)
    .RightMargin = Application.InchesToPoints(0.5)
    End With
    ElseIf OptionButton2.Value = -1 Then
    With Worksheets("Sheet1").PageSetup

    .PrintArea = "$A$60:$N$112"
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1

    .BottomMargin = Application.InchesToPoints(0.5)
    .TopMargin = Application.InchesToPoints(0.5)
    .LeftMargin = Application.InchesToPoints(0.5)
    .RightMargin = Application.InchesToPoints(0.5)
    End With
    ElseIf OptionButton3.Value = -1 Then
    With Worksheets("Sheet1").PageSetup

    .PrintArea = "$A$60:$N$112"
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 2

    .BottomMargin = Application.InchesToPoints(0.5)
    .TopMargin = Application.InchesToPoints(0.5)
    .LeftMargin = Application.InchesToPoints(0.5)
    .RightMargin = Application.InchesToPoints(0.5)
    End With
    End If

    Worksheets("Sheet1").PrintOut
    End Sub

    Private Sub cmdCancel_Click()
    Unload Me
    End Sub

    Private Sub UserForm_Initialize()
    OptionButton1.Value = 1
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1