Whenever working with Excel, you may face a situation where you will need to attach PDF files in Excel. The main focus of this article is to explain how to attach PDF file in Excel. 3 easy and simple ways of doing it will be explained.
How to Attach PDF File in Excel: 3 Easy Ways
For this article, I have taken a PDF file that contains the following table. The table has 3 columns, Employee ID, Employee Name, and Designation. I named the PDF file Employee Record. Here, I will attach this PDF file in Excel. I will explain 3 different ways of doing it.
1. Use Object Feature to Attach PDF File in Excel
In this first method, I will use the Object feature to attach a PDF file in Excel. Let’s see how it is done.
Steps:
- Firstly, select the cell where you want the PDF file.
- Secondly, go to the Insert tab.
- Thirdly, select Text.
- After that, a drop-down menu will appear.
- Select Object from the drop-down menu.
- Next, the Object dialog box will appear.
- Select the Create from File tab.
- Afterward, select Browse.
- Then, another dialog box named Browse will appear.
- Select the PDF file you want to attach.
- After that, select Insert.
- Next, check the Link to the file and Display as icon option.
- Finally, press OK.
- Now, you will see that you have attached the PDF file in Excel.
- After that, right-click on the PDF file.
- Then, select Format Object.
- Next, the Format Object dialog box will appear.
- Go to the Properties tab.
- Then, select Move and size with cells.
- Afterward, select OK.
- Now, the PDF file will be fixed in this cell. If you resize the cell the file will be resized automatically.
- You can open the PDF file by simply double-clicking on the PDF file.
Read More:Â [Fixed!] Cannot Insert Object in Excel
2. Employ Hyperlink Feature in Excel
The Hyperlinks feature helps to insert links in Excel. Here, I will use the Hyperlinks feature to attach PDF files in Excel. I will insert an image first and then link the PDF file to it. Let’s see the steps.
Steps:
- In the beginning, select the cell where you want the PDF file.
- Next, go to the Insert tab.
- After that, select Illustrations.
- Then, select Pictures.
- Consequently, a drop-down menu will appear.
- Select This Device from the drop-down menu.
- Now, another dialog box named Insert Picture will appear.
- Select the picture you want to insert.
- After that, select Insert.
- Then, you will see that the picture is inserted in Excel.
- Next, resize the image as per your need by clicking and dragging a corner of the image.
- Here, in the following picture, you can see how my picture looks after resizing.
- Further, right-click on the picture.
- Then, select Link.
- Afterward, the Insert Hyperlink dialog box will appear.
- Select Existing File or Web Page.
- Then, select the PDF file you want to attach.
- Next, select OK.
- Consequently, the link to the file will be inserted into the image. You can see the link if you hover your mouse cursor over the picture.
- In the end, click on the picture if you want to open the PDF file.
- In the following picture, you can see that I have opened the PDF file by clicking on the picture.
Read More:Â How to Insert PDF as Image in Excel
3. Use of VBA to Attach PDF File
In this method, I will show you how you can attach a PDF file in Excel by using VBA. I will write a simple VBA code and you can attach a PDF file in Excel by running it. Let’s see how you can do it.
Steps:
- First, go to the Developer tab.
- Then, select Visual Basic.
- Next, the Visual Basic Editor window will open.
- Select Insert tab.
- Then, select Module.
- Consequently, a module will open.
- After that, write the following code in that 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
🔎 How Does the Code Work?
- Here, I created a Sub Procedure named Attach_PDF_file.
- Then, I declared a variable named PDF_file as String.
- After that, I used a Do While Loop to repeat while the condition was true.
- Next, I used an If Statement to run the code for a specific condition.
- Afterward, I ended the If Statement.
- Finally, I ended the Sub Procedure.
- Next, Save the code and go back to your worksheet.
- Then, go to the Developer tab.
- After that, select Macros.
- Now, the Macro dialog box will appear.
- Select Attach_PDF_file as the Macro name.
- After that, select Run.
- Next, you will see that you have inserted the PDF file and you can see the first page on the display.
- After that, resize the PDF file as you want.
- In the following image, you can see how my PDF file looks after resizing.
- Then, double-click on the file to open the PDF.
- Here, you can see that I have opened my PDF file.
Read More: How to Attach Documents in Excel
How to Copy Data from PDF File to Excel
In this section, I will show you how you can copy data from PDF files to Excel. Here, I will use the Power Query Editor for this purpose. Let’s see the steps.
Steps:
- Firstly, go to the Data tab.
- Secondly, select Get Data.
- Thirdly, select From File.
- After that, select From PDF.
- Next, the Import Data dialog box will appear.
- Select the PDF file.
- Then, select Import.
- Here, the Navigator dialog box will appear.
- Select from where you want data. Here, I selected Page001.
- Then, select Transform Data.
- Consequently, the Power Query Editor will open.
- After that, click on the marked button on the following picture.
- Then, select Use First Row as Headers.
- Here, in the following image, you can see that I have got my desired table.
- Next, click on the drop-down option for Close & Load.
- Then select Close & Load To.
- Now, another dialog box named Import Data will appear.
- Select Existing Worksheet.
- Then, select the location where you want the data.
- After that, select OK.
- Consequently, you will see that you have copied the data from the PDF file to Excel.
- Finally, I formatted the table to get my desired output.
Read More:Â How Do I Insert a Multiple Page PDF into Excel
Things to Remember
Whenever working with VBA, you must save your Excel file as an Excel Macro-Enabled Workbook. Otherwise, the VBA will not work.
Practice Section
Here, I have provided a practice sheet for you to practice how to attach PDF files in Excel.
Download Practice Workbook
You can download the practice workbook from here.
Conclusion
To conclude, I tried to explain how to attach a PDF file in Excel in this article. Here, I explained 3 different methods. I also covered how you can copy data from PDF files to Excel. If you face any problems, then feel free to let me know in the comment section below.
Related Articles
- How to Insert an Excel File into Another Excel File
- How to Attach Email in Excel
- [Fixed!] Cannot Insert PDF into Excel
- How to Attach Zip File in Excel
- How to Attach Screenshot in Excel
<< Go Back to Attach File in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!