
Originally Posted by
SEOSEO.dk
I do NOT have the answer - but exactly the same issue. Look forward to see the administrators answer! Thank you aadeshgandhi to post this issue.
SEOSEO,
I was able to get two ways for it to work,
1) This will save the PDF in the same directory as the worksheet.
Sub SheetsToPDFs()
Dim strPath As String
Dim ws As Worksheet
strPath = ActiveWorkbook.Path & "\"
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "A" Or ws.Name = "B" Or ws.Name = "C" Or ws.Name = "D" Or ws.Name = "E" Or ws.Name = "F" Then
Else
ws.ExportAsFixedFormat xlTypePDF, strPath & ws.Name & ".pdf"
End If
Next ws
End Sub
2) This will save the PDF to the desktop.
Sub SheetsToPDFs()
Dim DeskTop As String
DeskTop = CreateObject("WScript.Shell").SpecialFolders("Desktop")
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "A" Or ws.Name = "B" Or ws.Name = "C" Or ws.Name = "D" Or ws.Name = "E" Or ws.Name = "F" Then
Else
ws.ExportAsFixedFormat xlTypePDF, Filename:=DeskTop & Application.PathSeparator & ws.Name & ".pdf"
End If
Next ws
End Sub
I hope this works for you.
Thanks,
Aadesh Gandhi
Bookmarks