Thread: Print Code
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Print Code

Chey

That's not the same code you posted two days ago that you said was giving the
error.

Remove the second TotPages line.

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 Fri, 13 Apr 2007 11:12:03 -0700, Chey wrote:

I have this code
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
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

When I run it ActiveSheet.PrintOut From:=x, To:=y
it wants a range from 1- a large number. When I run this part TotPages =
Application.ExecuteExcel4Macro("GET.DOCUMENT(50)" )
With ActiveSheet.PageSetup
x = 1
y = Range("AH42").Value
ActiveSheet.PrintOut From:=x, To:=y
End With
on the actual attendance sheet it runs fine. I am not sure what I am doing
wrong.
Thanks
Cheyenne