How to Attach a PDF File in Excel – 3 Easy Methods

The sample PDF file (Employee Record) contains the following table.

Dataset for how to Attach PDF File in Excel


Method 1 – Using the Object Feature to Attach a PDF File in Excel

Steps:

  • Select the cell in which you want the PDF file.
  • Go to the Insert tab.
  • Select Text.

Use Object Feature to Attach PDF File in Excel

  • In the drop-down menu, select Object.

  • In the Object dialog box, select Create from File.
  • Choose Browse.

Object Dialog Box to Attach PDF file in Excel

  • In Browse, select the PDF file you want to attach.
  • Click Insert.

  • Check Link to file and Display as icon.
  • Click OK.

You have attached the PDF file.

  • Right-click the PDF file.
  • Select Format Object.

Selecting Format Object to Attach PDF file in Excel

  • In the Format Object dialog box, choose Properties.
  • Select Move and size with cells.
  • Click OK.

  • The PDF file will be fixed in this cell. If you resize the cell the file will automatically be resized.
  • Open the PDF by double-clicking it.

Note: You can also open the Object dialog box, by pressing Alt + N +J.

Read More: [Fixed!] Cannot Insert Object in Excel


Method 2 – Using the Hyperlink Feature in Excel

Steps:

  • Select the cell in which you want the PDF file.
  • Go to the Insert tab.
  • Select Illustrations.
  • Choose Pictures.

Employ Hyperlink Feature in Excel

  • In the drop-down menu, select This Device.

Inserting Image to Attach PDF file in Excel

  • In Insert Picture, select the PDF.
  • Click Insert.

Selecting Picture to Attach PDF File in Excel

The picture is inserted.

  • Resize the image by clicking and dragging its corner.

REsizing Image to Attach PDF file in Excel

  • This is the output.

  • Right-click the picture.
  • Select Link.

Inserting Link to Attach PDF file in Excel

  • In the Insert Hyperlink dialog box, select Existing File or Web Page.
  • Select the PDF file you want to attach.
  • Click OK.

Insert Hyperlink Dialog Box to Attach PDF File in Excel

  • The link to the file will be inserted into the image. You can see it by hovering the cursor over the picture.
  • Click the picture to open the PDF file.

This is the output.

 


Method 3 – Using VBA to Attach a PDF File

Steps:

  • Go to the Developer tab.
  • Select Visual Basic.

Use of VBA to Attach PDF File in Excel

  • In the Visual Basic Editor window, select Insert tab.
  • Choose Module.

Opening Module to Attach PDF file in Excel

 

  • Enter the following code in the module.
Sub Attach_PDF_file()
Dim PDF_file As String
PDF_file = Dir("E:\office\Article 68\")
Do While Len(PDF_file) > 0
If Right(PDF_file, 3) = "pdf" Then
ActiveSheet.OLEObjects.Add(Filename:= _
"E:\office\Article 68\" & PDF_file _
, Link:=False, DisplayAsIcon:=False).Select
End If
PDF_file = Dir
Loop
End Sub

VBA Code to Attach PDF File in Excel

 Code Breakdown

  • A Sub Procedure named Attach_PDF_file is created.
  • A variable named PDF_file as String is declared.
  • A Do While Loop is used to repeat the loop while the condition is true.
  • An If Statement is used to run the code for a specific condition.
  • The If Statement is ended.
  • The Sub Procedure is ended.
  • Save the code and go back to your worksheet.
  • Go to the Developer tab.
  • Select Macros.

Running Macros to Attach PDF File in Excel

  • In the Macro dialog box, select Attach_PDF_file as the Macro name.
  • Click Run.

The PDF file is inserted and the first page is displayed.

  • Resize the PDF file.

This is the output.

  • Double-click the file to open the PDF.

This is the output.

Read More: How to Attach Documents in Excel


How to Copy Data from a PDF File to Excel

Use the Power Query Editor.

Steps:

  • Go to the Data tab.
  • Select Get Data.
  • Select From File.
  • Choose From PDF.

How to Copy Data from PDF File to Excel

  • In the Import Data dialog box, select the PDF file.
  • Click Import.

  • In the Navigator dialog box, select from where you want to get data. Here, Page001.
  • Click Transform Data.

  • The Power Query Editor will open.

  • Click the table button as shown in the following picture.
  • Select Use First Row as Headers.

This is the output.

  • Click Close & Load.
  • Select Close & Load To.

  • In Import Data, select Existing Worksheet.
  • Choose a location for your data.
  • Click OK.

  • Data in the PDF file was copied to Excel.

  • Format the table.

Read More: How Do I Insert a Multiple Page PDF into Excel


Things to Remember

Whenever working with VBA, save your Excel file as an Excel Macro-Enabled Workbook. Otherwise, VBA will not work.


Practice Section

Practice here.

Practice Sheet for how to Attach PDF File in Excel


Download Practice Workbook

Download the practice workbook here.


Related Articles


<< Go Back to Attach File in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Mashhura Jahan
Mashhura Jahan

Mashhura Jahan, BSc in Industrial and Production Engineering from Bangladesh University of Engineering and Technology, invested 1.5 years at ExcelDemy. In roles like Excel & VBA Content Developer, Excel Charts, and Dashboard course trainer, she wrote 90+ articles. She was previously part of the forum support team and a junior software analyst on the Excel Add-in project. With interests spanning Excel, VBA, Power Query, Python, Data Science, and Software Development, Mashhura brings a diverse skill set to her... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo