VBA宏中保存位置的对话框 [英] Dialog Box for Save As location in VBA Macro
本文介绍了VBA宏中保存位置的对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将文件导出为PDF,作为较大宏的一部分。但是,我希望用户可以选择将文件保存到他或她选择的目录中,我认为这将是最简单的浏览对话框。但是,我不知道如何拉一个。目前,我的代码如下。
I'm trying to export a file as a PDF as part of a larger macro. However, I'd like the user to have the option of saving the file to a directory of his or her choosing, and I think this would be easiest with a browsing dialog box. However, I can't figure out how to pull one up. Currently, my code reads as follows.
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\<filepath>\11.08E PT5 Executive Summary - v3.2.pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, From:=1, To:=3, OpenAfterPublish:=True
我想用对话框的结果替换。 / p>
I'd like to replace with the result of the dialog box.
推荐答案
Application.GetSaveAsFilename
。
dim v as variant
v = Application.GetSaveAsFilename("11.08E PT5 Executive Summary - v3.2.pdf", "PDF Files (*.pdf), *.pdf")
if vartype(v) = vbString then
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=v, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, From:=1, To:=3, OpenAfterPublish:=True
end if
这篇关于VBA宏中保存位置的对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文