批量把某个文件夹里的Excel文件发布成PDF文件,注意需前提设置好打印区域,打印缩放,当然这些你们也可以用代码实现!
Sub EXCEL转PDF()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = "C:\Users\" & Environ("username") & "\Desktop\"
If .Show = True Then Path = .SelectedItems(1) & "\"
End With
n = 2
myFile = Dir(Path & "*.xlsx")
Do While myFile <> ""
Cells(n, 1) = n - 1
Cells(n, 2) = myFile
arr = Split(myFile, ".xlsx")(0)
Workbooks.Open Path & myFile
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Path & arr & ".pdf"
Workbooks(myFile).Close True
myFile = Dir '找寻下一个文件
n = n + 1
Loop
End Sub