none
Runtime Error 1004 RRS feed

  • Question

  • I get this error when I click on button 3 to print a PDF, any help would be great.

    Sub Button3_Click()
    Application.ScreenUpdating = False
    ThisWorkbook.Unprotect "sabuk"
    Sheet1.Visible = xlSheetHidden
    Sheet5.Visible = xlSheetHidden

    Dim DTAddress As String
        DTAddress = "C:\RateCalculator\"
        
    fName = Range("d7").Value
    NewFile = DTAddress & fName & Format(Date, "-mmm-d-yyyy") & Format(Time, "-h.mm") & "-Post&Courier-Calculator-OrderSummary"

         ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFile, _
         Quality:=xlQualityStandard, IncludeDocProperties:=False, _
         IgnorePrintAreas:=False, OpenAfterPublish:=True

    Sheet1.Visible = xlSheetVisible
    Sheet5.Visible = xlSheetVisible
    ThisWorkbook.Protect "sabuk"

    End Sub

    Wes Cumbee

    Tuesday, July 29, 2014 7:34 PM

Answers

  • Hi Wes Cumbee,

    As far as I test, this issure is may relate to the name of PDF you exported. After I changed the name to a normal name like 'Book2.pdf', the code works well for me. Does it work work for you?

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 31, 2014 2:29 AM
    Moderator

All replies

  • You might want to put your code in a try/catch block so you can get the error message. It looks like it is probably a problem with range, but without the message that is a shot in the dark.

    David M. Nichols software engineer

    Tuesday, July 29, 2014 7:42 PM
  • That doesn't look like VB.Net code.  Is it VB6?
    Tuesday, July 29, 2014 7:45 PM
  • No it is VBA code from the looks of things. This forums is for VB.NET. VBA is a VB6 derivative that is found in Office applications like Excel and Word.

    As far as help with the actual question, what line does the error get thrown on? It also looks like you don't have a file extension on your export file name. Don't think that would cause the runtime error, but still something to check, unless excel auto appends an extension on export.


    Matt Kleinwaks - MSMVP MSDN Forums Moderator - www.zerosandtheone.com


    • Edited by kleinma Tuesday, July 29, 2014 7:53 PM
    Tuesday, July 29, 2014 7:49 PM
  • When I debugger lines 13 thur 15 are the ones highlighted. All I want it to do is when I push said button it exports the file to a pdf. Thanks.
    Wednesday, July 30, 2014 3:01 AM
  • When I debugger lines 13 thur 15 are the ones highlighted. All I want it to do is when I push said button it exports the file to a pdf. Thanks.

    Hi,

    I'm afraid that it is not the correct forum about this issue, since this forum is to discuss Visual Basic.

    So I have moved this thread to Excel for developer forum for better response.

    Thanks for your understanding.

    Best regards,
    Franklin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, July 30, 2014 3:18 AM
  • Hi Wes Cumbee,

    As far as I test, this issure is may relate to the name of PDF you exported. After I changed the name to a normal name like 'Book2.pdf', the code works well for me. Does it work work for you?

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 31, 2014 2:29 AM
    Moderator