Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Print from Option Buttons

Private Sub OptionButton1_click()
if OptionButton1.Value then
ActiveSheet.PageSetup.PrintArea = "'" & activesheet.name _
&"'!A3:N53")
' Other settings
End if
End Sub

Private Sub Userform_Initialize()

OptionButton1.Value = True
ActiveSheet.PageSetup.PrintArea = "'" & activesheet.name _
&"'!A3:N53")

End Sub

--
Regards,
Tom Ogilvy


" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Print from Option Buttons


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


--
kev_06
------------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
View this thread: http://www.excelforum.com/showthread...hreadid=566752

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
Option Buttons/Radio Buttons John Calder New Users to Excel 7 May 16th 08 03:51 AM
have toggle buttons but everytime print preview buttons move TinSandhu Excel Discussion (Misc queries) 1 October 11th 06 02:57 PM
Option buttons: How to get the selected option from a group? naddad Excel Programming 5 December 21st 05 05:09 PM
Navigating between option buttons is not selecting the option drhalter Excel Programming 1 June 3rd 05 02:28 PM
Navigating between option buttons is not selecting the option Gixxer_J_97[_2_] Excel Programming 4 June 2nd 05 02:50 PM


All times are GMT +1. The time now is 06:52 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"