Consulting

Results 1 to 4 of 4

Thread: Report Generator Fix - Run-time error '1004': Doc not saved

  1. #1

    Report Generator Fix - Run-time error '1004': Doc not saved

    Hi everyone, new to the forums, as well as VBA. Trying to fix a Run-time error '1004' when I attempt to generate a report in Excel.
    After the error, clicking debug highlights this line of code:

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strPDFFileName

    Is there an obvious mistake I'm making here or will I need to include some more information?

    Appreciate the help.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    There is a "Document not saved" error if that PDF file is open on the PC.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    File wasn't open, but already existed. All I had to do was change the filename, lol very silly but thank you.

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You can use the Kill command to delete an existing file before creating a new version.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Tags for this Thread

Posting Permissions

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