+ Reply to Thread
Results 1 to 2 of 2

Macro to create PDF's question

  1. #1
    Registered User
    Join Date
    07-14-2006
    Posts
    1

    Macro to create PDF's question

    Hi. I have macro that does the following:

    1) Opens a spreadsheet with 6 tabs (worksheets)
    2) Selects one tab, and prints using the Acrobat Disiller as a printer
    3) Saves this file as "aseries.pdf"
    4) Goes back to the spreadsheet and selects the next tab
    5) Repeats the .pdf creation, saving the next tab as bseries.pdf
    6) and so forth for all six tabs, saving as a different name

    In the end, I will have 6 .pdf files created all with different names

    The only problem I am having is, when these files get created, they are all saved in "My Documents" folder. I'm trying to save them in a certain folder.

    The code I've used is as follows:

    Application.ScreenUpdating = False

    Workbooks.Open Filename:="L:\RATES\External Domestic " & Format(Date, "MMDDYY") & ".xls"
    Sheets("A Series").Select
    Application.ActivePrinter = "Acrobat PDFWriter on LPT1:"
    ChDir "L:\rates\"

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
    "Acrobat PDFWriter on LPT1:", prtofilename:="L:\rates\aseries"
    Kill "L:\rates\aseries"

    Sheets("B Series").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printToFile:=True, _
    prtofilename:="L:\rates\bseries"
    Kill "L:\rates\bseries"

    Sheets("C Series").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printToFile:=True, _
    prtofilename:="L:\rates\cseries"
    Kill "L:\rates\cseries"

    Sheets("D Series").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printToFile:=True, _
    prtofilename:="L:\rates\dseries"
    Kill "L:\rates\dseries"

    Sheets("E Series").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printToFile:=True, _
    prtofilename:="L:\rates\eseries"
    Kill "L:\rates\eseries"

    Sheets("F Series").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, printToFile:=True, _
    prtofilename:="L:\rates\fseries"
    Kill "L:\rates\fseries"

    Application.ScreenUpdating = True


    Can someone tell me what I am doing wrong?

    Thanks!
    Last edited by joeyarsenault19; 07-14-2006 at 12:10 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    I suspect that you might need to use the ChDrive statement to change the default drive before you try to save the files

    ChDrive L
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1