excel - 如何将exel打印为PDF,不包括第一张纸
问题描述
我正在尝试将 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
解决方案
选择除第一张以外的所有工作表:
Dim x As Long, wb As Workbook
Set wb = ActiveWorkbook
wb.Sheets(2).Select
For x = 3 To Sheets.Count
wb.Sheets(x).Select False
Next x
打印...
推荐阅读
- c# - 如果使用 ADO.NET 的参数值为 NULL,我可以创建条件查询以跳过 AND 条件吗?
- r - 使用 Cassandra“in”子句的 Sparklyr 查询问题
- cmake - cmake 从目录中删除自定义输出结果
- php - PHP:无法使用管理员帐户登录
- wordpress - 这个链接是从哪里生成的?我想将此链接重定向到博客主页
- python - 在 Python 中使用 Firebase-Admin 解压 AuthError(例如 Dict)
- java - 在 docker 文件中下载打开的 java sdk
- ios - 谷歌登录 iOS 与服务器
- pyspark - Databricks PySpark Job 不断被取消
- elasticsearch - 将特定的 CPU 资源分配给 pod - kubernetes.io/limit-ranger: 'LimitRanger 插件集:容器弹性搜索的 cpu 请求'