【发布时间】:2015-06-30 17:49:11
【问题描述】:
我想循环浏览一个 PDF 文件文件夹并将文件插入到 word 文档的相应文本框中。
我在网上找不到太多关于它的信息,但我尝试在循环遍历 excel 文件的文件夹时对我的代码进行建模...我没有尝试让它插入 PDF,但我正在尝试解决这个问题第一的。顺便说一句,我有 Adobe Reader 而不是 Adobe Professional,如果有帮助的话。
我调试了代码,错误在Set fromPDF = AcroExch.PDDoc.Open(sPath & sFile)...
任何帮助将不胜感激。
Sub UseTextBox()
Dim reportDoc As Object
Dim str As String
Dim tag As String
Dim pdfName As String
Set reportDoc = ActiveDocument
MsgBox reportDoc
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
'match PDF to figure and insert
Set SelectFolder = Application.FileDialog(msoFileDialogFolderPicker)
With SelectFolder
.Title = "Select Directory"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo ResetSettings
sPath = .SelectedItems(1) & "\"
End With
sFile = Dir(sPath & "*pdf")
Do While sFile <> ""
Set fromPDF = AcroExch.PDDoc.Open(sPath & sFile)
pdfName = sFile
For Each objShape In reportDoc.Shapes
If objShape.Type = msoTextBox Then
str = objShape.TextFrame.TextRange.Text
If InStr(str, "(") > 0 Then
tag = BetweenParentheses(objShape.TextFrame.TextRange)
MsgBox tag
End If
End If
Next objShape
sFile = Dir
Loop
ResetSettings:
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
End Sub
【问题讨论】: