Save as PDF button

%3CLINGO-SUB%20id%3D%22lingo-sub-239388%22%20slang%3D%22en-US%22%3ESave%20as%20PDF%20button%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-239388%22%20slang%3D%22en-US%22%3EHello%20I%20am%20trying%20to%20make%20a%20section%20of%20a%20excel%20file%20save%20as%20a%20pdf%2C%20but%20I%20cannot%20seem%20to%20do%20it.%20Can%20anyone%20please%20help%3F%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-239388%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Emacro%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESavePDF%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-239427%22%20slang%3D%22en-US%22%3ERe%3A%20Save%20as%20PDF%20button%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-239427%22%20slang%3D%22en-US%22%3E%3CP%3ETry%20this%20in%20place%20of%20your%20code.%20You%20might%20need%20to%20check%20the%20paths%20to%20make%20sure%20they%20are%20correct.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20told%20it%20to%20name%20the%20pdf%20document%20whatever%20is%20in%20the%20B21%20(ie%20the%20family%20name%2C%20but%20again%20you%20should%20be%20able%20to%20change%20that%20if%20that's%20not%20what%20you%20wanted.%20If%20you%20hard%20code%20the%20file%20name%20though%20you%20will%20saving%20over%20the%20top%20of%20the%20same%20document%20every%20time.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EPrivate%20Sub%20CommandButton2_Click()%3CBR%20%2F%3Efile_name%20%3D%20Sheets(%22progression%20chart%22).Range(%22B21%22)%3CBR%20%2F%3ESheets(%22Progression%20chart%22).Range(%22A1%3AK74%22).ExportAsFixedFormat%20Type%3A%3DxlTypePDF%2C%20Filename%3A%3D%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22%5C%5CProliant1%5Cpsl%5CData%20Feedback%5CPDF%20File%5C%22%20%26amp%3B%20file_name%20%26amp%3B%20%22.pdf%22%2C%20Quality%3A%3D%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20xlQualityStandard%2C%20IncludeDocProperties%3A%3DTrue%2C%20IgnorePrintAreas%3A%3DFalse%2C%20_%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OpenAfterPublish%3A%3DTrue%3CBR%20%2F%3EEnd%20Sub%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor
Hello I am trying to make a section of a excel file save as a pdf, but I cannot seem to do it. Can anyone please help?
1 Reply
Highlighted

Try this in place of your code. You might need to check the paths to make sure they are correct.

 

I've told it to name the pdf document whatever is in the B21 (ie the family name, but again you should be able to change that if that's not what you wanted. If you hard code the file name though you will saving over the top of the same document every time.

 

Private Sub CommandButton2_Click()
file_name = Sheets("progression chart").Range("B21")
Sheets("Progression chart").Range("A1:K74").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "\\Proliant1\psl\Data Feedback\PDF File\" & file_name & ".pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
End Sub