+ Reply to Thread
Results 1 to 7 of 7

Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

  1. #1
    Registered User
    Join Date
    10-22-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    4

    Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    Hi Everyone,

    I've been trying (and failing) to solve an error the following bit of VBA for the last few weeks, and I haven't seen someone post online with a similar issue.

    Essentially, I have a bit of code that creates a few hundred PDFs based on information held in other sheets. The code looks like this:

    Please Login or Register  to view this content.
    Randomly I will get the following error: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    The line highlighted is the PDF export line.

    Hitting resume continues the code, but there will a PDF from the selection that has been missed.

    ufProgress is a userform for marking the progress of the macro for users of the sheet.

    As you may be able to tell, savepath refers to a network location (which I do have permissions to access). I just ran the code without error when saving to C:\PDFs.

    Any help would be greatly appreciated.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    If you just get one sheet that errors, my first assumption is that the file name is not valid

  3. #3
    Registered User
    Join Date
    10-22-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    4

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    I'd agree, however, the filename always looked fine when I go into debug. It's set up in the below lines:

    Please Login or Register  to view this content.

    The cell on the PDF sheet has the following formula to ensure the length of a filename is four numbers:

    =IF(LEN(F2)=4,F2,IF(LEN(F2)=3,"0"&F2,IF(LEN(F2)=2,"00"&F2,"000"&F2)))

    So shouldn't be throwing up any errors when all of the values of F2 are 1 - 4 digit numbers.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    10-22-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    4

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    It's going to be next to impossible to upload a copy of the workbook. The error only occurs when I'm running it when the lastStore value is in the high hundreds, which is far too much data for me to desensitise.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    what is the actual file name when the error happens?

  7. #7
    Registered User
    Join Date
    10-22-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    4

    Re: Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    The issue doesn't occur on the same file every time (otherwise it would be an obvious fix - and I've checked to make sure that the file names aren't error values). They're always a network file path (generally) G:\PDFs\ and a four digit number followed by .pdf. For example:

    G:\PDFs\1242.pdf

+ 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] Run-time error '1004': Method 'Range' of object '_worksheet' failed
    By Ms2BSwagg in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-31-2021, 12:25 PM
  2. Run-time error '1004' - Method 'Range' of object '_Worksheet' failed
    By Veronik in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-25-2018, 03:17 PM
  3. Run-time error '1004': Method 'ExportAsFixedFormat' of object '_Worksheet' failed
    By jlshores in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-09-2017, 02:48 PM
  4. Run-Time Error '1004': Method 'Visible' of Object'_Worksheet' Failed
    By caltman242 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2015, 10:43 AM
  5. run-time error '1004' method 'range' of object '_worksheet' failed
    By Emma_B in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-26-2014, 09:00 AM
  6. Run time Error 1004 Method 'Range' object '_Worksheet 'failed
    By Monica1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2013, 07:42 AM
  7. me too - run-time error '1004' method 'range' of object '_worksheet' failed
    By ASAFSWIS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-07-2013, 05:14 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