Create PDF FILE with name retrieved from a cell

marco -  
 marco -
Hello,

as a novice in macros, I'm turning to you for help.
I want to save my file as a PDF in the same directory as my Excel file, retrieving its name from a cell.
I’d like to specify two things: the Excel file is located on an internal server (I don't know if that matters).
The cell where the name to be retrieved is located uses the formula
=CONCATENATE(E11;" "; B12;" "; E12)
to create the name.
Thank you in advance for your help!

Configuration: Windows / Firefox 72.0

3 answers

  1. cs_Le Pivert Posted messages 8437 Status Contributor 730
     
    Hello,

    like this:

    Sub savepdf() Dim nom As String ' name of the pdf Dim chemin As String 'path of the save folder nom = Range("A1").Value 'adapt cell chemin = ActiveWorkbook.Path & "\" ' same folder as the workbook 'save as PDF ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ chemin & nom, Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ False End Sub 


    --
    @+ The Pivert
    0
    1. marco
       
      Hello,

      thank you for your response and your promptness.
      Indeed, it works very well!!!
      I would like to push this a bit further if possible.
      Let me explain. Could there be an error message if a PDF file with the same name already exists in the directory?
      Thanks again!
      0