Excel工作表依次转换为PDF文件代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Sub SelectFile()

On Error Resume Next

Application.ScreenUpdating = False

Dim FileName As Variant

Dim sFileName As String

Dim sPathName As String

Dim aFile As Variant

Dim fn, i%

Dim Sht As Worksheet

Dim WKbook As Workbook

FileName = Application.GetOpenFilename("Excel 文件(*.*),*.*", MultiSelect:=True)

For Each fn In FileName

Set WKbook = Workbooks.Open(fn)

For i = 1 To WKbook.Sheets.count

Set Sht = WKbook.Sheets(i)

Sht.Activate

With ActiveSheet.PageSetup

.CenterHorizontally = False

.CenterVertically = False

.Orientation = xlLandscape

.FitToPagesWide = 1

.FitToPagesTall = 1

.PrintErrors = xlPrintErrorsDisplayed

End With

Sht.ExportAsFixedFormat Type:=xlTypePDF, FileName:=ActiveWorkbook.path + "¥" & VBA.Left(, Len() - 4)

& "" + "" & & "" + ".pdf", Quality:= _

xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True,

OpenAfterPublish:=False

Next i

WKbook.Close False

Next

Application.ScreenUpdating = True MsgBox "Done."

End Sub

相关文档
最新文档