Hello,
I am attempting to add a specific file (C:\user\bordiway\desktop\dashboards) for this macro to pdf to. I cant seem to get it to work. Can someone help? Thank you in advance.
Public Sub Print_to_PDF_Click()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
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
ThisWorkbook.Sheets("Provider Dashboard").Select
Set wsA = ActiveSheet
strTime = Format(Now(), "yyyymmdd\_hhmm")
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strFile = Sheets("SelectedProvider").Range("B1").Text & " " & Sheets("SelectedProvider").Range("B3").Text & ".pdf"
strPathFile = strPath & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& myFile
End If
exitHandler:
Worksheets("Provider Dashboard").Select
Exit Sub
errHandler:
Worksheets("Provider Dashboard").Select
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
I am attempting to add a specific file (C:\user\bordiway\desktop\dashboards) for this macro to pdf to. I cant seem to get it to work. Can someone help? Thank you in advance.
Public Sub Print_to_PDF_Click()
Dim wsA As Worksheet
Dim wbA As Workbook
Dim strTime As String
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
ThisWorkbook.Sheets("Provider Dashboard").Select
Set wsA = ActiveSheet
strTime = Format(Now(), "yyyymmdd\_hhmm")
strPath = wbA.Path
If strPath = "" Then
strPath = Application.DefaultFilePath
End If
strPath = strPath & ""
strFile = Sheets("SelectedProvider").Range("B1").Text & " " & Sheets("SelectedProvider").Range("B3").Text & ".pdf"
strPathFile = strPath & strFile
myFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If myFile <> "False" Then
wsA.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'confirmation message with file info
MsgBox "PDF file has been created: " _
& vbCrLf _
& myFile
End If
exitHandler:
Worksheets("Provider Dashboard").Select
Exit Sub
errHandler:
Worksheets("Provider Dashboard").Select
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub