I found this code on the Internet but it doesn't work on my computer. Can anybody explain to me why? I want to save sheets to different and separate pdfs files.
here is the code
Sub ExportAsPDF()
Dim Folder_Path As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select Folder path"
If .Show = -1 Then Folder_Path = .SelectedItems(1)
End With
If Folder_Path = "" Then Exit Sub
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
sh.ExportAsFixedFormat xlTypePDF, Folder_Path & Application.PathSeparator & sh.Name & ".pdf"
Next
MsgBox "Done"
End Sub
And it doesn't work. It writes Run-time error 5 Invalid procedure call or argument What's wrong with it?