+ Reply to Thread
Results 1 to 9 of 9

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

Hybrid View

jlshores Run-time error '1004': ... 06-09-2017, 12:36 PM
CK76 Re: Run-time error '1004': ... 06-09-2017, 12:45 PM
jlshores Re: Run-time error '1004': ... 06-09-2017, 12:56 PM
CK76 Re: Run-time error '1004': ... 06-09-2017, 01:07 PM
jlshores Re: Run-time error '1004': ... 06-09-2017, 01:44 PM
CK76 Re: Run-time error '1004': ... 06-09-2017, 01:51 PM
jlshores Re: Run-time error '1004': ... 06-09-2017, 02:09 PM
CK76 Re: Run-time error '1004': ... 06-09-2017, 02:44 PM
jlshores Re: Run-time error '1004': ... 06-09-2017, 02:48 PM
  1. #1
    Registered User
    Join Date
    06-09-2017
    Location
    USA
    MS-Off Ver
    2016 for Mac
    Posts
    5

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

    Hello, looking for some help on exporting a sheet to a PDF. Using Excel for MAC 2016. this is driving me crazy. Everywhere i search the same syntax is used, yet not for me.

    the macro runs, initially i get a "Save" box telling me it is preparing
    then a print error box,
    once i hit OK I get
    Run-time error '1004':

    Method 'ExportAsFixedFormat' of object '_Worksheet' failed

    Sub PDF()
    Dim wksheet As Worksheet
    Dim filename As String

    Set wksheet = ThisWorkbook.Sheets("Calculator")

    filename = ActiveWorkbook.Path & "temppdf.pdf"

    With wksheet
    .PageSetup.PrintArea = Range("A1", "N46").Address
    End With

    wksheet.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    filename:=filename, _
    quality:=xlQualityStandard, _
    includedocproperties:=True

    End Sub

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

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

    Likely culprit.
    filename = ActiveWorkbook.Path & "temppdf.pdf"
    You should change to...
    filename = ActiveWorkbook.Path & "\" & "temppdf.pdf"
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    06-09-2017
    Location
    USA
    MS-Off Ver
    2016 for Mac
    Posts
    5

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

    Thank you CK76. Provided fix and still same issue???

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

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

    Hmm, worked fine on my end. Tested on my co-worker's Mac.

    Sub PDF()
    Dim wksheet As Worksheet
    Dim filename As String
    
    Set wksheet = ThisWorkbook.Sheets("Calculator")
    
    filename = ActiveWorkbook.Path & "\" & "temppdf.pdf"
    
    With wksheet
    .PageSetup.PrintArea = Range("A1", "N46").Address
    End With
    
    wksheet.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    filename:=filename, _
    quality:=xlQualityStandard, _
    includedocproperties:=True
    
    End Sub

  5. #5
    Registered User
    Join Date
    06-09-2017
    Location
    USA
    MS-Off Ver
    2016 for Mac
    Posts
    5

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

    At least it works some place. Im running it on a MacBook Air, OS X El Capitan V.10.11.6.

    Do you think this could be the problem???

    Thank you

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

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

    I don't think so.

    Only other problem that I can think of is... if the Activeworkbook is on Network shared drive, and when you don't have appropriate permission to save files.

  7. #7
    Registered User
    Join Date
    06-09-2017
    Location
    USA
    MS-Off Ver
    2016 for Mac
    Posts
    5

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

    for some reason it does not like the ExportAsFixedFormat command. Any others that I could use?

    Thank you

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

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

    Hmm, from what I can find, Excel 2016 on Mac has few bugs (my colleague's Mac has Excel 2011).

    Try going through Ron de Bruin's site. His site is one of the best resources on Mac VBA.
    Link below is for saving PDF on Mac (works for Excel 2016).
    https://www.rondebruin.nl/mac/mac005.htm

  9. #9
    Registered User
    Join Date
    06-09-2017
    Location
    USA
    MS-Off Ver
    2016 for Mac
    Posts
    5

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

    Thank you for all your help. Ill post fix if i can figure out whats wrong

+ 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. 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
  2. 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
  3. [SOLVED] How can I resolve this Run-Time error '1004': Method 'Range' of object '_Worksheet' failed
    By dafella in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2013, 01:16 AM
  4. [SOLVED] Run-time error '1004': Method 'Select' of object'_Worksheet' failed
    By vbiggs101 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-07-2013, 02:56 PM
  5. 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
  6. 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
  7. [SOLVED] Name a dynamic range - Run-time error 1004 Method 'Range' of object'_Worksheet' failed
    By DavidBW in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2012, 08:00 AM

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