Thread: Print Code
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Chey Chey is offline
external usenet poster
 
Posts: 52
Default Print Code

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