使用VBA将批量的WORD文档转换为PDF
Sub BatchConvertToPDF()
Dim destFolderPath As String
destFolderPath = GetFolderPath
If destFolderPath <> Empty Then
Dim path As Variant
For Each path In GetFilePaths()
Dim indexOfSlash, indexOfDot As Integer
indexOfSlash = InStrRev(path, "\")
indexOfDot = InStrRev(path, ".") Dim destFilePath As String
destFilePath = destFolderPath + Mid(path, indexOfSlash, indexOfDot - indexOfSlash) + ".pdf" ConvertToPDF path, destFilePath
Next path
End If
End Sub Function GetFilePaths()
Dim folderPath As String
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Add "word文件", "*.doc; *.dotx; *.docm"
.Title = "请择要转换的word文件"
If .Show = -1 Then
Set GetFilePaths = .SelectedItems
End If
End With
End Function Function GetFolderPath()
Dim folderPath As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Title = "请选择要存放的目录"
If .Show = -1 Then
GetFolderPath = .SelectedItems(1)
End If
End With
End Function Sub ConvertToPDF(srcPath As Variant, destPath As String)
Documents.Open FileName:=srcPath, ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
destPath, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForOnScreen, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ActiveDocument.Close
End Sub
使用VBA将批量的WORD文档转换为PDF的更多相关文章
- 批量转换word文档到pdf文件
最近在整理每周的工作记录.因为每周的工作记录大都是单独的word文件,有时候忘记了也不容易找出来,一个个打开查找太费劲,因此想着把这些文件通过word2016的另存为功能转换为pdf,然后永Acrob ...
- Java 使用 jacob 将 word 文档转换为 pdf 文件
网上查询了许许多多的博客,说利用 poi.iText.Jsoup.jdoctopdf.使用 jodconverter 来调用 openOffice 的服务来转换等等,我尝试了很多种,但要么显示不完全, ...
- DEV word文档转换为pdf文件
引用aspose.net控件2.0. docement doc=new document(文件路径和名称); doc.save(输出路径\file.pdf);
- C# 导出word文档及批量导出word文档(1)
这里用到了两个dll,一个是aspose.word.dll,另外一个是ICSharpCode.SharpZipLib.dll,ICSharpCode.SharpZipLib.dll是用于批量 ...
- C# 导出word文档及批量导出word文档(4)
接下来是批量导出word文档和批量打印word文件,批量导出word文档和批量打印word文件的思路差不多,只是批量打印不用打包压缩文件,而是把所有文件合成一个word,然后通过js来调用 ...
- Python批量创建word文档(2)- 加图片和表格
Python创建word文档,任务要求:小杨在一家公司上班,每天都需要给不同的客户发送word文档,以告知客户每日黄金价格.要求在文档开始处给出banner条,价格日期等用表格表示.最后贴上自己的联系 ...
- Python批量创建word文档(1)- 纯文字
Python创建word文档,任务要求:小杨在一家公司上班,每天都需要给不同的客户发送word文档,以告知客户每日黄金价格.最后贴上自己的联系方式.代码如下: 1 ''' 2 #python根据需求新 ...
- 在linux中使用php将word文档转为pdf
使用本教程需要在linux中安装openoffice,改页面中有详细的安装与使用教程(http://www.cnblogs.com/sustudy/p/3999628.html). 既然,你看了该教程 ...
- word文档转pdf,支持.doc和.docx,另附抽取pdf指定页数的方法
公司有个需求,需要将word转成pdf并且抽取首页用以展示,word文档有需要兼容.doc和.docx两种文档格式.其中.docx通过poi直接就可以将word转成pdf,.doc则无法这样实现,上网 ...
随机推荐
- c++ inheritance -- 继承
c++ inheritance -- 继承 终于要决心弄明白继承了,以前仅限于大学时学习,以后工作也没有用,现在就依照(百度百科)文章写些测试的代码. 文章说 ==================== ...
- J2EE开发框架搭建(2) - springmvc4 + spring4 + hibernate4 整合
1. 打开hqhop-framework-parent项目下的pom.xml文件.加入springmvc4 , spring4 , hibernate4 ,以及数据源druid的依赖包,插件,依赖包版 ...
- c#indexof使用方法
IndexOf() 查找字串中指定字符或字串首次出现的位置,返首索引值,如: str1.IndexOf("字"): //查找"字"在str1中的索引值(位置) ...
- Swift - 给表格的单元格UITableViewCell添加图片,详细文本标签
表格UITableView中,每一单元格都是一个UITableViewCell.其支持简单的自定义,比如在单元格的内部,添加图片和详细文本标签. 注意UITableViewCell的style: (1 ...
- Swift - 运算符重载和运算符函数
让已有的运算符对自定义的类和结构进行运算或者重新定义已有运算符的运算规则,这种机制被称为运算符重载. 1,通过重载加号运算符,使自定义的两个坐标结构体对象实现相加: 1 2 3 4 5 6 7 8 9 ...
- SharePoint场管理-PowerShell(二)
1. 合并Log文件 Merge-SPLogFile –Path E:\Logs\MergedLog.log –StartTime "1/19/2010" –Overwrite 2 ...
- [Django实战] 第4篇 - 用户认证(用户登录)
今天来实现用户登录模块 首先,我们创建一个表单(forms.py): from django import forms from django.contrib.auth.models import U ...
- Bdsyn百度手机助手是何物,它是怎样神不知鬼不觉地安装到你的电脑里的?
[电脑软件管理中Bdsyn手机助手的问题]Bdsyn手机助手 is developed by Baidu, Inc. and is used by 10 users of Software Infor ...
- codeforces 592B The Monster and the Squirrel
题目链接:http://codeforces.com/contest/592/problem/B 题目分类:数学,找规律 题目分析:重要的是画图找规律 代码: #include<bits/s ...
- MySql 链接url 参数详解
最近 整理了一下网上关于MySql 链接url 参数的设置,有不正确的地方希望大家多多指教: mysql JDBC URL格式如下: jdbc:mysql://[host:port],[host:po ...