Save as PDF button

Copper 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

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