David Haywood
New Member
Dera all,
I am using a very simple VBA code to name and save a .pdf file from an Excel worksheet:
This works but I have one problem and one question.
Problem: "B1" and "B3" are dates but the .pdf name does not capture/display the year; i.e. the name looks like this: Name 23/10/ to 1/11/.pdf; I would also like the dates to be in this format: Name 2018/10/23 to 2018/11/1.pdf so that they automatically sort themselves in date order when filed. Can this be done?
Question: Currently the macro saves the .pdf to my desktop - but I would like to send the Excel file out to others on Mac and Microsoft platforms so that they can use the macro to save the .pdf on their desktops - is there a generic address I can use?
thanks
David
I am using a very simple VBA code to name and save a .pdf file from an Excel worksheet:
Code:
Sub SavePDF()
' Dim fname As String
With ActiveSheet
fname = .Range("B1").Value & (" ") & .Range("B3").Value & (" to ") & .Range("C3").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"Macintosh HD:Users:davidhaywood:Desktop:" & fname, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End With
End Sub
This works but I have one problem and one question.
Problem: "B1" and "B3" are dates but the .pdf name does not capture/display the year; i.e. the name looks like this: Name 23/10/ to 1/11/.pdf; I would also like the dates to be in this format: Name 2018/10/23 to 2018/11/1.pdf so that they automatically sort themselves in date order when filed. Can this be done?
Question: Currently the macro saves the .pdf to my desktop - but I would like to send the Excel file out to others on Mac and Microsoft platforms so that they can use the macro to save the .pdf on their desktops - is there a generic address I can use?
thanks
David
Last edited by a moderator: