+ Reply to Thread
Results 1 to 5 of 5

Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

  1. #1
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

    Hi All,

    I have been working on this project for a long time and it is finally nearly done. I have a chunk of code that is intended to grab a range of cells from a form and export that range as a PDF file with a dynamic file name. This was working fine on my computer but when I tried to run the project on my coworker's computer (for whom the project is intended), I got a 1004 Error. The error box says that the PDF may be open, but there were no pdf's open and since the file name is dynamic I don't understand what it's talking about.

    Both my coworker and myself are running Office 2016. Their computer does have Adobe Reader installed and I can manually export the range as a PDF just fine but the code does not work. Looking forward to any thoughts. My code is below:

    Please Login or Register  to view this content.
    Thank you

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,246

    Re: Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

    Try it maybe in this way:
    Please Login or Register  to view this content.
    Ps.:
    1) use "&" to concatenate strings, not "+"
    2) The 'ChDir' statement changes the default directory but not the default drive

  3. #3
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

    porucha vevrku,

    I apologize for not responding sooner. I haven't been able to work on this until now. I tried your code both with and without the "Possible but not needed" sections. Both version of your code produce the following error at the ws.ExportAsFixedFormat command line:

    "Run-Time error '-2147024773(8007007b)': Document not saved."

    Yes, ws. is declared earlier in the procedure. I should have posted my entire code, though. My full code, with your input, is below.

    Please Login or Register  to view this content.
    Thank you for your help. I appreciate it.

  4. #4
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

    I may have figured it out. The "Location" string was pulling from a dynamic range that sometimes contained ":" or "\" or other offending characters. I've removed these characters from the range and it seems to be working. My code is below:

    Please Login or Register  to view this content.
    If it works on my coworkers computer I will mark this as solved.
    Last edited by TFiske; 04-20-2018 at 06:30 PM.

  5. #5
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: Error 1004 Document Not Saved .ExportAsFixedFormat xlTypePDF

    Yes, that appears to have been the problem. The code is working now and generating a pdf with the dynamic name as intended. I've added the following code to all userform controls related to generating the pdfName string to prevent users from entering special characters into those fields:

    Please Login or Register  to view this content.
    I will mark this as solved.
    Last edited by TFiske; 04-20-2018 at 03:36 PM. Reason: Added code to allow spaces

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Once successful VBA now elicits Run-time error '1004': Document not saved.
    By Matthew55 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-31-2017, 12:57 PM
  2. [SOLVED] Runtime Error 1004: Document Not Saved (ExportAsFixedFormat)
    By Sophie.Durrant in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2015, 11:16 AM
  3. Run-time error 1004 Document not saved....
    By ey_up in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2014, 04:47 AM
  4. Run-time error '1004': Document Not Saved (while using LockXLS)
    By lottidotti in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2013, 12:14 PM
  5. ExportAsFixedFormat xlTypePDF not giving same results as native PDF export
    By Rick_HpyVly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2013, 03:32 PM
  6. Excel 2007 : Run Time Error 1004 - Document not saved
    By Villamankh in forum Excel General
    Replies: 2
    Last Post: 12-17-2010, 09:44 AM
  7. Run-time error '1004'; Document not saved - intermittent
    By Kerry in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-15-2005, 07:15 PM

Tags for this Thread

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