How to Read .pdf Documents with VBA for Word in Microsoft 365 and Windows 10
Alex F
26
Reputation points
When I try to run the following script, I get the error "This PDF contains interactive features that are not supported by PDF Reflow. Word will not display this content.”
Sub ExtractHighlightedTextsInSameColorFromMultiDoc()
Dim objDoc As Document, objDocAdd As Document
Dim strFile As String, strFolder As String
Dim objRange As Range
' Initialization
strFolder = "C:\Users\MYPATH\OneDrive\Documents\Test Folder\"
strFile = Dir(strFolder & "*.pdf", vbNormal)
Set objDocAdd = Documents.Add
' Precess each file in the file folder.
While strFile <> ""
Set objDoc = Documents.Open(FileName:=strFolder & strFile)
With Selection
.HomeKey Unit:=wdStory
With Selection.Find
.Highlight = True
Do While .Execute
If Selection.Range.HighlightColorIndex = wdYellow Then
Set objRange = Selection.Range
objDocAdd.Range.InsertAfter objRange & vbCr
objDocAdd.Range.InsertAfter strFolder & strFile & vbCr
Selection.Collapse wdCollapseEnd
End If
Loop
End With
End With
objDoc.Close
strFile = Dir()
Wend
End Sub
I use FoxitPDF Editor. However, I tried making Adobe Reader my default .pdf program and I still get the same error message.
Is there any way to fix this?
Developer technologies Visual Basic for Applications
1,508 questions
Sign in to answer