我有以下代码将工作表存储为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
答案 0 :(得分:2)
如果您始终希望在没有任何用户干预的情况下保存到桌面:
PdfFile = createobject("Wscript.Shell").Specialfolders("Desktop") & "\" & PdfFile & ".pdf"
答案 1 :(得分:1)
Rory的答案的另一种选择,可能是使用windows环境变量" userprofile"
PdfFile = Environ("userprofile") & "\desktop\" & PdfFile & ".pdf"