gpt4 book ai didi

excel - 在桌面上将 Excel 工作表存储为 PDF

转载 作者:行者123 更新时间:2023-12-04 22:04:34 25 4
gpt4 key购买 nike

我有以下代码将工作表存储为 PDF。我想控制它的存储位置——即他们的桌面。有人可以给我一个提示如何做到这一点。谢谢!

Sub SaveAsPDF()
Dim i As Long
Dim PdfFile As String, Title As String

' Not sure for what the Title is
Title = Range("B1")

' Define PDF filename
PdfFile = Range("F3")
i = InStrRev(PdfFile, ".")
If i > 1 Then PdfFile = Left(PdfFile, i - 1)
PdfFile = PdfFile & ".pdf"

' Export activesheet as PDF
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With

End Sub

最佳答案

如果您总是想在没有任何用户干预的情况下保存到桌面:

PdfFile = createobject("Wscript.Shell").Specialfolders("Desktop") & "\" & PdfFile & ".pdf"

关于excel - 在桌面上将 Excel 工作表存储为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26801651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com