Is there a way to create an excel sheet to PDF and have it save in 2 locations?
Is there a way to create an excel sheet to PDF and have it save in 2 locations?
Hi RWSM
You can just repeat the save line with 2 locations.
In the attached file, the code in Module 1 is as follows. It saves the active sheet as a pdf (with the sheet name) in two locations. You will need to change the folder locations in bold:
Sub SavePdfX2()
Dim ws As Worksheet
Dim SvLoc1 As String, SvLoc2 As String
'Set folder locations
SvLoc1 = "E:\Documents\Spreadsheets\TeachExcel files"
SvLoc2 = "E:\Documents\Spreadsheets\TeachExcel files\Test files"
Set ws = ActiveSheet
' reuse variables to name pdfs
SvLoc1 = SvLoc1 & "\" & ws.Name & ".pdf"
SvLoc2 = SvLoc2 & "\" & ws.Name & ".pdf"
'save two pdfs (overwriting if necessary)
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvLoc1, Quality:=xlQualityStandard
ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=SvLoc2, Quality:=xlQualityStandard
'tell user
MsgBox "Saved as: " & vbCr & vbCr & SvLoc1 & vbCr & vbCr & SvLoc2
End Sub
Hope this helps.