【发布时间】:2021-06-22 06:52:35
【问题描述】:
我正在尝试将 Excel 工作簿打印为 pdf,但从 PDF 中排除标题为基本信息的第一张工作表。目前整个工作簿都包含在 PDF 中
Option Explicit
Sub CreatePDF()
Dim IsCreated As Boolean
Dim PdfFile As String, Title As String
Dim s As Worksheet
Dim DoNotInclude As String
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
Title = "I&T Plan for " & Worksheets("Basic Information").Range("C7").Value
PdfFile = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Title & ".pdf"
Sheets("Front Sheet").Select
DoNotInclude = ("Basic Information")
For Each s In ActiveWorkbook.Worksheets
If s.Visible = True Then
If InStr(DoNotInclude, s.Name) = 0 Then
s.Select (False)
End If
End If
Next
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, fileName:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With
Sheets("Front Sheet").Select
MsgBox "Created PDF file on the desktop", vbOKOnly, "I&T PDF"
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub
【问题讨论】:
-
有什么问题?它工作正常。
-
如上所述,基本信息表包含在 PDF 中