Excel sheet save as pdf in specific folder vba macro

Share
Embed
  • Published on Aug 14, 2017
  • Sub Save_PDF ()

    Sheets("Sheet1").Select
    Dim filename As String
    Dim ChDir As String




    filename = Range("A1")
    ChDir = "C:\Users\AntoJ\Documents\Test\"
    Sheets("Sheet1").Range("a1:d20").ExportAsFixedFormat Type:=xlTypePDF, filename:= _
    ChDir & filename & ".pdf", Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
    False
    End Sub
  • Howto & StyleHowto & Style

Comments • 12

  • Pynio Pde
    Pynio Pde 7 months ago +1

    run time error 5 invalid procedure call or argument!!! Someone Help

  • Radhika Basnet
    Radhika Basnet 7 months ago

    compile error,sub or function not define. help me in this error

  • uberteen999
    uberteen999 9 months ago

    EXCELLENT TUTORIAL! great content, keep it up!

  • Tushar Mehta
    Tushar Mehta Year ago

    i am getting the invalid cell argument please guide

    • Walid Dami
      Walid Dami 8 months ago

      Check the reference cell in Sheets("Sheet1").ExportAsFixedFormat

  • antshamac
    antshamac Year ago

    Hi @The Jerkooo I tried also got run time error 1004 document could not save.
    example of vba code

  • Clement Andoh
    Clement Andoh Year ago

    Sheets("Sheet1").Select ERROR (subscript out of range) please help

    • TheJerkooo
      TheJerkooo  Year ago

      Hi, please check the name of your sheet, for this code it must be "Sheet1"

  • Zackd41pro
    Zackd41pro Year ago +1

    worked just fine thanks

  • funnybomb
    funnybomb Year ago +1

    run time error 1004 document could not be saved

    • funnybomb
      funnybomb Year ago

      @TheJerkooo thanks

    • TheJerkooo
      TheJerkooo  Year ago +1

      Hi, you need to put your file location in vba code - ChDir