Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-03-2017, 10:05 PM
gmayor's Avatar
gmayor gmayor is offline Insert PDF into Word Windows 10 Insert PDF into Word Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

An Excel function? I thought you wanted to insert the PDF into Word? If you put a macrobutton field where you want the PDF. The size of the PDF will be determined by the distance between the margins at that point.

{ MACROBUTTON InsertPDF Click to select and insert PDF file }

and double click that field to run the InsertPDF macro below, it will insert the selected PDF at the field location
Code:
Sub InsertPDF()
'Graham Mayor - http://www.gmayor.com - Last updated - 04/03/2017
Dim strPDF As String
Dim oRng As Range
    Set oRng = Selection.Range
    strPDF = BrowseForFile
    If Not strPDF = vbNullString Then
        oRng.Text = ""
        ActiveDocument.InlineShapes.AddOLEObject _
                ClassType:="AcroExch.Document.DC", _
                FileName:=strPDF, _
                LinkToFile:=False, _
                DisplayAsIcon:=False, _
                Range:=oRng
    End If
lbl_Exit:
    Exit Sub
End Sub

Private Function BrowseForFile() As String
'Graham Mayor - http://www.gmayor.com - Last updated - 04/03/2017
Dim fDialog As FileDialog
    On Error GoTo Err_Handler
    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
    With fDialog
        .Title = "Select the document to insert"
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PDF Format", "*.pdf"
        .InitialView = msoFileDialogViewTiles
        If .Show <> -1 Then GoTo Err_Handler:
        BrowseForFile = fDialog.SelectedItems.Item(1)
    End With
lbl_Exit:
    Exit Function
Err_Handler:
    BrowseForFile = vbNullString
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
insert, pdf



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert PDF into Word How do I insert pictures directly into picture boxes by clicking the box instead of using INSERT>PIC Bree Word 1 06-24-2016 10:32 PM
Insert PDF into Word Insert Captions and Word Wrap TEAllred Word 1 11-22-2015 03:21 PM
Insert PDF into Word Is there anyway I can insert an easy bookmark in word? BayhDole Word 2 07-21-2015 08:43 PM
insert video into word doc Wordstop Word 2 07-19-2013 07:01 AM
how insert big word doc. into an email tbklus Word 0 09-15-2010 01:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft