none
in code vb Import multiple PDFs into word doc RRS feed

  • Question

  • I have been searching for a VB code example where two or more PDFs are imported/inserted into a word document each on a new top of page.

    Is there a VB code example?

     
    Wednesday, September 21, 2016 4:00 PM

Answers

  • >>>I have been searching for a VB code example where two or more PDFs are imported/inserted into a word document each on a new top of page.

    According to your description, you could use InlineShapes.AddOLEObject method to embed a pdf file in Word, refer to below VBA codes:
    Sub Demo()
    
        Const strFolder As String = "D:\"
        Const strPattern As String = "*.pdf"
        Dim strFile As String
        strFile = Dir(strFolder & strPattern, vbNormal)
        Do While Len(strFile) > 0
            Selection.InsertBreak wdPageBreak
            Selection.InlineShapes.AddOLEObject ClassType:="AcroExch.Document.7", _
                FileName:=strFolder & strFile, LinkToFile:=False, _
                DisplayAsIcon:=False
            strFile = Dir
        Loop
    
    End Sub

    For more information, click here to refer about InlineShapes.AddOLEObject Method (Word)

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Friday, September 30, 2016 2:14 AM
    • Marked as answer by David_JunFeng Friday, September 30, 2016 2:14 AM
    Thursday, September 22, 2016 4:43 AM