Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Chaplain Doug
 
Posts: n/a
Default Creating a PDF file programatically from Excel

Excel 2003. I am using the following code to create a separate Excel file
and PDF file for each sheet in my workbook. The .SaveAs works fine and
creates a file without prompting me. However, the .PrintOut prompts me for
the file name and location for the PDF file. How may I make it create the
PDF file without a prompt? As a subquestion, how may I set my default
working directory so that the .SaveAs and the .PrintOut direct their output
to this directory? Thanks and God bless.

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.SaveAs "C:\Documents and Settings\doug.GNJPM\My
Documents\Excel\Budgets 2005\Temp\" & wb.Sheets(1).Name & ".xls"
wb.PrintOut , , , , "Adobe PDF"
wb.Close False
Set wb = Nothing
Next a
Application.ScreenUpdating = True
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Corrupt File / Urgent cpayne1757 Excel Discussion (Misc queries) 7 March 6th 07 03:20 AM
Problem opening an XML file in Excel - getting "ns1:macrosPresent" rprondeau Excel Discussion (Misc queries) 0 December 15th 04 03:39 PM
Saving a Excel 97 file into Excel 2003 file Wil Excel Discussion (Misc queries) 1 December 13th 04 11:51 PM
Using Jet to read excel file returns blank for last cell - sometim Ron Excel Discussion (Misc queries) 1 December 9th 04 08:21 AM
Cannot open a file that Excel says is open Plodhia Excel Discussion (Misc queries) 2 December 7th 04 01:43 AM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"