Print
So far so good except
ActiveSheet.PrintOut From:=X, To:=y
It says is has to be between 1 and some large number.
Thanks for your time.
"Gord Dibben" wrote:
You could do it all in one macro or two separate macros.
Here is a single macro that prints page 1 of 1 from Request Form then prints the
number of pages found in AH42 on Attendance Sheet.
Please forgive the "selects". Too busy to correct right now.
Private Sub CommandButton1_Click()
Dim TotPages As Long
Dim x As Long
Dim y As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
Sheets("Request Form").Select
With ActiveSheet.PageSetup
ActiveSheet.PrintOut From:=1, To:=1
End With
Sheets("Attendance Sheet").Select
With ActiveSheet.PageSetup
x = 1
y = Range("AH42").Value
ActiveSheet.PrintOut From:=x, To:=y
End With
End Sub
Gord
On Wed, 11 Apr 2007 15:32:02 -0700, Chey wrote:
I hope I don't drive you nuts but I actually wanted to add to this.
I want the button on sheet "Request Form"
I want this sheet to print page 1 of 1
and then I want the code you just gave me also
that sheet is called "Attendance Sheet"
I am I able to do all that or do I need to buttons.
"Gord Dibben" wrote:
Chey
Delete the line Sub Print_Pages.
You have wrapped my Sub into a CommandButton Sub.
Gord
On Wed, 11 Apr 2007 13:16:02 -0700, Chey wrote:
Private Sub CommandButton1_Click()
Sub Print_Pages()
Dim TotPages As Long
Dim x As Long
Dim y As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
With ActiveSheet.PageSetup
x = 1
y = Range("AH42").Value
ActiveSheet.PrintOut From:=x, To:=y
End With
End Sub
this is what I have but it says compile error expect end sub.
Thanks again
Cheyenne
"Gord Dibben" wrote:
Sub Print_Pages()
Dim TotPages As Long
Dim x As Long
Dim y As Long
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
With ActiveSheet.PageSetup
x = 1
y = Range("AH42").Value
ActiveSheet.PrintOut From:=x, To:=y
End With
End Sub
Gord Dibben MS Excel MVP
On Wed, 11 Apr 2007 11:34:02 -0700, Chey wrote:
I want to put a command button on my excel spreadsheet. I have how many
pages in a cell example in cell AH42 will say 3. How do I tell it to print
pages 1-(whatever the number in AH42) is?
Thanks
Cheyenne
|