+ Reply to Thread
Results 1 to 9 of 9

Run time error '1004' application defined or object defined error, PDF won't save

Hybrid View

  1. #1
    Registered User
    Join Date
    06-26-2023
    Location
    Maryland, USA
    MS-Off Ver
    2016
    Posts
    3

    Question Run time error '1004' application defined or object defined error, PDF won't save

    For months this has been working and then today it randomly stopped working. ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, FileName:=path & fname & ".pdf" is what was highlighted so the error must be there. Please help.


    Sub SaveAsPdf()

    Dim invno As Long
    Dim custname As String
    Dim amt As Currency
    Dim dt_issue As Date
    Dim term As Byte
    Dim path As String
    Dim fname As String
    Dim nextrec As Range

    invno = Range("C3")
    custname = Range("B9")
    amt = Range("H40")
    dt_issue = Range("C4")
    term = Range("C5")
    path = "D:\Content\Invoices"
    fname = invno & " - " & custname


    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, FileName:=path & fname & ".pdf"


    Set nextrec = Sheet4.Range("A1048576").End(xlUp).Offset(1, 0)

    nextrec = invno
    nextrec.Offset(0, 1) = custname
    nextrec.Offset(0, 2) = amt
    nextrec.Offset(0, 3) = dt_issue
    nextrec.Offset(0, 4) = dt_issue + term

    Sheet4.Hyperlinks.Add anchor:=nextrec.Offset(0, 6), Address:=path & fname & ".pdf"

    Exit Sub


    End Sub

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,696

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    try
    path = "D:\Content\Invoices\"    '<----- Backslash added at the end
    Or instead
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, FileName:=path & "\" & fname & ".pdf"     '<----- Backslash added between path & fname
    The inherent weakness of the liberal society: a too rosy view of humanity.

  3. #3
    Registered User
    Join Date
    06-26-2023
    Location
    Maryland, USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    Neither of these worked. Same message.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Run time error '1004' application defined or object defined error, PDF won't save


    Check the variables contents …

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    3,037

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    You can also get a 1004 error if the sheet being pdf'd is blank.

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,696

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    or add a single line after the path line, like so
    path = "D:\Content\Invoices"
    If Not Right(path, 1) = "\" Then path = path & "\"
    Attached Images Attached Images

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,696

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    Have you checked the suggestions made by Marc L and ByteMarks?

  8. #8
    Registered User
    Join Date
    06-26-2023
    Location
    Maryland, USA
    MS-Off Ver
    2016
    Posts
    3

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    For some reason it’s working fine on my PC but not on my Mac. Thanks for your help though.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,696

    Re: Run time error '1004' application defined or object defined error, PDF won't save

    I am not lucky enough to have an Apple product so I can't test/check.
    Thanks for letting us know that all is well in the Microsoft world though.
    Good Luck with it also.

+ 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'; Application-defined or object-defined error on Pivot Table VBA
    By GordonKy42 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-27-2022, 10:55 AM
  2. [SOLVED] Error message: Run-Time error '1004 '; application-defined or object-defined error
    By Davasu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 06:52 AM
  3. VBA ERROR: run time error 1004: Application-defined or Object-defined error in excel 2013
    By AnanthKrishna in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 06:16 AM
  4. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  5. Replies: 1
    Last Post: 03-12-2014, 12:42 PM
  6. [SOLVED] Run time error 1004 Application-Defined or Object-Defined Error - Placing data into next e
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-27-2014, 12:57 PM
  7. [SOLVED] run-time error '1004' application-defined or object-defined error - Excel 2007
    By kaurka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-06-2012, 02:46 AM

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