|
楼主 |
发表于 2022-3-25 16:09
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
<免手打>PDF转Word
- Option Explicit
- Sub ConvertPDF2WordFile(pathPDF As String)
- ' Dim objWord As New Word.Application
- ' Dim objDoc As Word.Document
- Dim objWord As Object, objDoc As Object
- Dim TrimFile As String
- Set objWord = CreateObject("Word.Application")
- Set objDoc = CreateObject("Word.Document")
-
- On Error Resume Next
- Set objDoc = objWord.Documents.Open(pathPDF)
- On Error GoTo 0
-
- If Not objDoc Is Nothing Then
- TrimFile = Left(objDoc.Name, InStrRev(objDoc.Name, ".") - 1)
- objDoc.SaveAs2 Filename:=objDoc.Path & "" & TrimFile, FileFormat:=wdFormatDocumentDefault
- End If
- objDoc.Close: Set objDoc = Nothing
- Shell "powershell.exe kill -processname winword", vbMinimizedFocus
- End Sub
- Sub test()
- Dim fn As String
- fn = "C:\Temp\testConvert.pdf"
- ConvertPDF2WordFile fn
- End Sub
复制代码 |
|