利用WORD的宏批量把WORD转换为PDF
答案:4 悬赏:60 手机版
解决时间 2021-11-09 05:12
- 提问者网友:喧嚣尘世
- 2021-11-08 22:25
利用WORD的宏批量把WORD转换为PDF
最佳答案
- 五星知识达人网友:想偏头吻你
- 2021-11-08 23:08
宏代码如下:
Option Explicit
Dim FileAddress As String
Dim TargetAddress As String
Sub Main()
Application.ScreenUpdating = False
Dim tempStr
FileAddress = "C:\Userfile "
TargetAddress = "C:\Userfile \PDF\"
tempStr = Dir(FileAddress & "\*.docx")
While tempStr <> ""
Documents.Open FileAddress & "\" & tempStr
SaveAsPdfFile
Documents(tempStr).Close False
tempStr = Dir
Wend
Application.ScreenUpdating = True
End Sub
Sub SaveAsPdfFile()
Dim strDocName, strPdfName As String
Dim intPos As Integer
' Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
' If the document has not yet been saved
' Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else
' Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strPdfName = strDocName & ".pdf"
End If
' Save file with new extension
ActiveDocument.SaveAs2 FileName:=TargetAddress & strPdfName, _
FileFormat:=wdFormatPDF
End Sub
Option Explicit
Dim FileAddress As String
Dim TargetAddress As String
Sub Main()
Application.ScreenUpdating = False
Dim tempStr
FileAddress = "C:\Userfile "
TargetAddress = "C:\Userfile \PDF\"
tempStr = Dir(FileAddress & "\*.docx")
While tempStr <> ""
Documents.Open FileAddress & "\" & tempStr
SaveAsPdfFile
Documents(tempStr).Close False
tempStr = Dir
Wend
Application.ScreenUpdating = True
End Sub
Sub SaveAsPdfFile()
Dim strDocName, strPdfName As String
Dim intPos As Integer
' Find position of extension in file name
strDocName = ActiveDocument.Name
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
' If the document has not yet been saved
' Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else
' Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strPdfName = strDocName & ".pdf"
End If
' Save file with new extension
ActiveDocument.SaveAs2 FileName:=TargetAddress & strPdfName, _
FileFormat:=wdFormatPDF
End Sub
全部回答
- 1楼网友:由着我着迷
- 2021-11-09 02:01
这个只要把后缀改下就可以实现转换。。。追问什么意思?怎么改?
- 2楼网友:渡鹤影
- 2021-11-09 00:32
word文档批量处理大师有这个功能的,另外,该软件7.1版增加了批量运行vba宏代码的功能,有了该功能,所有使用者都可以自己定制适合自己的功能了,极为强悍,最新版需要在该软件的官方网站下载
- 3楼网友:罪歌
- 2021-11-09 00:00
我不会用宏,提供以下方法:
步骤:
1. 把所有需转换的Word文档放在一下文件夹里
2. Ctrl+A 选择全部文档 (如果太多可能转换起来会很慢)
3. 右击->选择 [转换成Adobe PDF]
4. 会提示你另存为
前提要装PDF程式,Acrobat8 或 Acrobat9都可以,网上有下载。 求采纳啊
步骤:
1. 把所有需转换的Word文档放在一下文件夹里
2. Ctrl+A 选择全部文档 (如果太多可能转换起来会很慢)
3. 右击->选择 [转换成Adobe PDF]
4. 会提示你另存为
前提要装PDF程式,Acrobat8 或 Acrobat9都可以,网上有下载。 求采纳啊
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯