gpt4 book ai didi

VBA “Save to PDF” 即使在取消时也会保存

转载 作者:行者123 更新时间:2023-12-04 20:14:27 26 4
gpt4 key购买 nike

我有一个宏的问题。即使我在“保存”对话框中按“取消”,我也想避免宏保存 PDF 文件。我错过了什么?

这是代码:

Set ws = Foglio5

'enter name and select folder for file
' start in current workbook folder
strFile = Replace(Replace(Foglio5.Cells(14, 2) & "_" & (Foglio5.Cells(14, 4) & "_" & (Foglio5.Cells(15, 10))), "", ""), ".", "_") _
& "_" _
& Format(Foglio5.Cells(17, 5), "yyyymmdd\") _
& ".pdf"
strFile = ThisWorkbook.Path & "\" & strFile

myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")

If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

MsgBox "PDF Creato! Si trova nella cartella di questo file."
End If

exitHandler:
Exit Sub
errHandler:
MsgBox "Errore nella creazione del PDF"
Resume exitHandler
End Sub

我尝试改变:
If myFile <> "False" Then

进入:
If myFile Then

现在它不再工作了,它说无法保存 PDF。

最佳答案

myFile <> "False"

应该
myFile <> False

ref

关于VBA “Save to PDF” 即使在取消时也会保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31248407/

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