+ Reply to Thread
Results 1 to 9 of 9

Macro works fine until documents closed

  1. #1
    Registered User
    Join Date
    03-22-2007
    Posts
    23

    Macro works fine until documents closed

    Created a basic time saving macro assigned to Personal.xlbs that prints spreasheets I receive in emails to PDF. Works great right after I create the macro and run it on some open spreadsheets but after I close Excel and re-open it Macro no longer works. Used thes basic steps:

    Open a target spreadsheet.
    Developer > Record Macro >
    Give it a name and Shortcut Key
    Sore in > Personal.xlbs
    Record Macro: File > Print > Pritner = PDF > Print All Pages > Print > Choose filename and target save location
    Stop Recording

    Open some othe spreadsheets and it works great.

    Close Excel and re-open it and it no longer works. Macro sends it directly to local printer instead of PDF as I chose in the Macro Record steps.

    Any guideance appreciated ;^)

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Macro works fine until documents closed

    I think it is because you didn't set printer to PDF in your macro (or that property wasn't set by macro recorder).
    Make sure your default printer is PDF or implement correct printer choose.

    P.s. attach you workbook, then we will try to help you.

    Best Regards

  3. #3
    Registered User
    Join Date
    03-22-2007
    Posts
    23

    Re: Macro works fine until documents closed

    Quote Originally Posted by maczaq View Post
    I think it is because you didn't set printer to PDF in your macro (or that property wasn't set by macro recorder).
    Make sure your default printer is PDF or implement correct printer choose.

    P.s. attach you workbook, then we will try to help you.

    Best Regards
    Thanks for the reply. Wasnt sure which workbook is needed for posting (worbook or personal.xlsb). Wont let me attach the .xlsb one ....
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-22-2007
    Posts
    23

    Re: Macro works fine until documents closed

    Correct. When I set PDF as default printer it worked. Would prefer to not have to change default printer to PDF each time, then reset back to notrmal default printer. Possible tweak?

  5. #5
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Macro works fine until documents closed

    if that attached workbook contain confidental data consider to delete it immediatly.

    try to use this part of code for set printer
    Please Login or Register  to view this content.
    Best Regards
    MaczaQ

  6. #6
    Registered User
    Join Date
    03-22-2007
    Posts
    23

    Re: Macro works fine until documents closed

    Macro now shows:
    Sub SchedulesPDF()
    '
    ' SchedulesPDF Macro
    '
    ' Keyboard Shortcut: Ctrl+q
    '
    ActiveWorkbook.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
    Application.ActivePrinter = "Adobe PDF Converter"
    End Sub

    But throws this error: Run-time error 1004: Method "ActivePrinter" of object "_Application" failed

  7. #7
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Macro works fine until documents closed

    first set printer, then printOut
    Please Login or Register  to view this content.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro works fine until documents closed

    gunslinger,

    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    03-22-2007
    Posts
    23

    Re: Macro works fine until documents closed

    Still throws same error. Wonder if I dont have the correctn name for the Adobe PDF Printer though Ive tried both "PDFCreator" and "Adobe PDF Converter" as it appears in pritner properties.

    I will read the forum rules now. Sorry about thta.

+ 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