+ Reply to Thread
Results 1 to 2 of 2

Run time error 1004 save excel as pdf

  1. #1
    Registered User
    Join Date
    06-02-2016
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    14

    Run time error 1004 save excel as pdf

    I have this VBA code to save the active sheet as PDF file:

    Dim fName As String
    fName = Range("E1").Value
    ChDir "C:\Users\sally\Desktop"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\sally\Desktop\Daily Department Report- " & fName, Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True


    I tried this com with my com and the code works perfectly.
    However, when I change to another computer, I changed the path name accordingly. Instead of sally (original computer user name), I changed it to mary. Please see the new code:

    Dim fName As String
    fName = Range("E1").Value
    ChDir "C:\Users\mary\Desktop"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\mary\Desktop\Daily Department Report- " & fName, Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True

    At this point, when I try to run the code, it gives me this error message:

    Run-time error 1004

    Document not saved. The document may be open, or an error may have been encountered when saving.

    Does anyone knows why?

  2. #2
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: Run time error 1004 save excel as pdf

    your code works for me here well. Only one thing, please make sure you have data in cell E1.

+ 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 save as wont work and I dont know why!
    By vmandonado in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-01-2014, 03:31 AM
  2. [SOLVED] [HELP!] Run-time error 1004 on object click email save and send
    By ld2x07 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2014, 10:04 AM
  3. [SOLVED] Run-time error 1004/Save file macro
    By egglee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-04-2013, 06:22 AM
  4. Run-time error 1004 - save as pdf problem
    By vvujke in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-05-2013, 10:03 PM
  5. [SOLVED] run time error 1004 method save as of object _workbook failed
    By johnsmith2004ad in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-21-2013, 02:02 AM
  6. Run time error 1004 method save as of object 1 "_workbook" failed.
    By json_79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2012, 02:41 AM
  7. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 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