pdf - 我可以从文档中更改保存为目的地,以便我收到一个选择目的地的弹出窗口吗?
问题描述
目前以下编码正在工作,但它会自动保存在代码中定义的文件夹中。
Private Sub CommandButton2_Click()
' Button PDF '
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"\\Desktop\Test_PDF.pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportFromTo, From:=2, To:=7, Item:= _
wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub
我想更改可以选择保存目的地的代码,所以如果我按下按钮,我会收到一个弹出窗口。
解决方案
例如:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strTxt As String
strFolder = GetFolder
If strFolder = "" Then
MsgBox "No Save Folder Selected!", vbCritical
Exit Sub
Else
ActiveDocument.ExportAsFixedFormat _
OutputFileName:=strFolder & "\Test_PDF.pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=True, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportFromTo, From:=2, To:=7, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:=wdExportCreateNoBookmarks, _
DocStructureTags:=True, BitmapMissingFonts:=True, UseISO19005_1:=False
End If
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose the folder to save in", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
推荐阅读
- ms-access - 将共享点链接到访问权限
- javascript - Javascript 数组作为更具可读性的数组
- wordpress - 为移动应用程序构建 WooCommerce 的 REST API
- gnuplot - gnuplot“跳过没有有效点的数据文件”
- c - 将内存分配给指向指针变量的指针时出现分段错误 [C]
- ios - Xcode - 警告 ITMS-90735 - 无效的可执行部分 - 提交到 App Store
- python - Odoo10:给定客户编号时,如何自动获取合作伙伴的价值?
- r - 如何用 ggplot2 制作横幅/彩色框?
- android - 生成带有反应本机原因错误的未签名 APK:verifyReleaseResources'
- java - 无障碍服务中的意图分离