![]() |
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 |
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 |
All times are GMT +1. The time now is 02:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com