I have been trying to write a macro that when run will print each sheet in a selection to PDF and name each PDF the name of the sheet. For example, if I have selected Sheet 1, Sheet 2 and Sheet 3 in a workbook. I want a macro that when executed will print Sheet1 to PDF and name the PDF "Sheet 1". Then it will print Sheet 2 to PDF and name the PDF "Sheet 2". Then it will print Sheet 3 to PDF and name the PDF "Sheet 3".
Here is what I have been trying but it doesn't work:
I feel like this shouldn't be hard but it is stumping me. Please help!
Here is what I have been trying but it doesn't work:
VBA Code:
Sub ExportPDFSelectionSheets()
Dim ws As Worksheet
Dim Path As String
Dim Name As String
Path = "H:\(H) Sandbox\(H) Scans\"
For i = 1 To ActiveWindow.SelectedSheets.Count
Set ws = ActiveWindow.SelectedSheets(i)
Name = ws.Name
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Path & Name & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next i
End Sub
I feel like this shouldn't be hard but it is stumping me. Please help!