littlejilly
Board Regular
- Joined
- Sep 8, 2011
- Messages
- 168
Hello All,
I have an excel workbook with several sheets in it. On the Summary tab, I have added in an ActivX command button in hopes that I can correctly write code that will copy the content seen on the sheet (values only) and copy it to a pdf and open the file.
I have used the following code but I am coming up with an error:
I have colored the line in red where I receive the following error:
Run-time error '1004': The number must be between 1 and 32767. Try again by entering a number in this range.
I am not even sure that this is the correct code. I dont necessaily need to print automatically but if I could at least get the pdf to open with a copy of the summary tab, that would be most helpful.
Any suggestions are greatly appreciated.
I have an excel workbook with several sheets in it. On the Summary tab, I have added in an ActivX command button in hopes that I can correctly write code that will copy the content seen on the sheet (values only) and copy it to a pdf and open the file.
I have used the following code but I am coming up with an error:
Rich (BB code):
Private Sub PrintPDF_Click()
Dim fileName As String
Sheets("Summary").Select
'set the path and file name
fileName = "C:WINDOWSDesktopsheet1.PDF"
'Enters the name and path of the PDF file when the PrintFileAs dialog box is opened
SendKeys fileName & "{ENTER}", False
'prints the file
Worksheets(1).PrintOut ActivePrinter = "Acrobat PDFWriter on LPT1:"
end sub
I have colored the line in red where I receive the following error:
Run-time error '1004': The number must be between 1 and 32767. Try again by entering a number in this range.
I am not even sure that this is the correct code. I dont necessaily need to print automatically but if I could at least get the pdf to open with a copy of the summary tab, that would be most helpful.
Any suggestions are greatly appreciated.