Hi. I have the macro below which upon running converts the active sheet in excel to pdf.
2 Issues I'm running into:
1. The pdf name comes in weird numbers. Example, instead of WORK AS OF 06-22-2019, it comes as 6ORK AS OF 06-21-2019.
2. There is a sheet call 'total' in my workbook which I want to be automatically included every-time while converting to pdf along with the active sheet that they will run the macro on.
Please help.
Thank you in advance.
Code:
Sub SaveasPDF()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strName As String
Dim strPath As String
Dim strFile As String
Dim strPathFile As String
Dim myFile As Variant
On Error GoTo errHandler
Set wbA = ActiveWorkbook
Set wsA = ActiveSheet
'get active workbook folder, if saved
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strName = Format (Now(), "WORK AS OF MM-DD-YYYY")
'create default name for savng file
strFile = strName & ".pdf"
strPathFile = strPath & strFile
'export to PDF in current folder
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strPathFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& strPathFile
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
[B][/B]
1. The pdf name comes in weird numbers. Example, instead of WORK AS OF 06-22-2019, it comes as 6ORK AS OF 06-21-2019.
2. There is a sheet call 'total' in my workbook which I want to be automatically included every-time while converting to pdf along with the active sheet that they will run the macro on.
Please help.
Thank you in advance.
Last edited by a moderator: