ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Printer Options Programmatically (https://www.excelbanter.com/excel-programming/319151-setting-printer-options-programmatically.html)

Chaplain Doug

Setting Printer Options Programmatically
 
Excel 2003. I am trying to create PDF files from each of the sheets in my
workbook. I am using the code:

Sub test()
Dim a As Integer
Dim wb As Workbook
Application.ScreenUpdating = False
For a = 1 To ThisWorkbook.Worksheets.Count
ThisWorkbook.Sheets(a).Copy
Set wb = ActiveWorkbook
wb.PrintOut , , , , "Adobe PDF"
wb.Close False
Set wb = Nothing
Next a
Application.ScreenUpdating = True
End Sub

This works fine the first time I "print" to a PDF file, since I set the
printer not to prompt for file name, etc. However, when I move to the next
sheet the printer options have been reset. How may I set the options for the
printer programmatically before each .PrintOut? Thanks.


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com