我有一个宏用于导出所有工作表以在指定的子文件夹中分隔pdf。当我执行它时,在正确的位置生成pdfs并且标题为apporproately但是然后出错 - 错误5无效的过程调用或参数 - 任何想法?
Sub SaveWorkshetAsPDF()
Application.ScreenUpdating = False
Dim ws As Worksheet
Dim path As String
Dim fol As String
Dim name As String
Dim concat As String
Dim fdObj As Object
path = ActiveWorkbook.path
fol = "\PDFs\"
Set fdObj = CreateObject("Scripting.FileSystemObject")
If fdObj.FolderExists(path & fol) Then
MsgBox "Found it", vbInformation
Else
fdObj.createfolder (path & fol)
MsgBox "folder created", vbInformation
End If
For Each ws In Worksheets
name = ws.name
concat = path & fol & name
With ws.PageSetup
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = False
.PaperSize = xlPaperA3
End With
ws.ExportAsFixedFormat xlTypePDF, fileName:=concat
Next ws
Application.ScreenUpdating = True
End Sub