Prevost
Board Regular
- Joined
- Jan 23, 2014
- Messages
- 198
Hi,
I have the code below that saves the worksheet as a pdf with a certain name in a certain folder. I have this code several times throughout my macro and so my question is, can I make this into a function (and how I would do that) that I can call to make my code much neater? Also, if I wanted to change the parameters, such as the PDF name and file location, how would I go about performing that?
Thanks!
One more thing, I am unsure of when to use a Class or a Function, or if this is a case where I could use either. Any explanation would greatly help.
I have the code below that saves the worksheet as a pdf with a certain name in a certain folder. I have this code several times throughout my macro and so my question is, can I make this into a function (and how I would do that) that I can call to make my code much neater? Also, if I wanted to change the parameters, such as the PDF name and file location, how would I go about performing that?
Thanks!
One more thing, I am unsure of when to use a Class or a Function, or if this is a case where I could use either. Any explanation would greatly help.
Code:
Sub Make_PDF()
'this names the file the value of C7
'also specifies the location of the saved pdf file
Dim pdfName As String
pdfName = Range("C7").Text
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Users\100043059\Desktop\" & pdfName & ".pdf" _
, Quality:=xlQualityMedium, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Last edited: