Follow Me

Converting Office Documents to PDF with the Office Interop Assemblies

By Stefan Feenstra   /     May 21, 2014  /     Office, SharePoint 2010, SharePoint 2013  /     , , ,

Converting Office Documents to PDF

If you want to convert a document to PDF you can save it as PDF (File -> Export -> PDF). But what if you have a lot of documents you want to convert to PDF. Then the Office Interop Assemblies could help you. This blog explains how you could use the Office Interop Assemblies to convert Word, PowerPoint and Excel files to PDF.

Prerequisites:
– Microsoft Office needs to be installed
– Some dev skills

This is not something you would like to use on a large production environment. But if you are in need of a onetime solution this could be a solution. Always keep in mind that you backup your Office documents and check the results after converting.

Word

Add Assembly reference to project: Microsoft.Office.Interop.Word

Code:

PowerPoint

Add Assembly reference to project: Microsoft.Office.Interop.PowerPoint

Code:

Excel

Add assembly reference to project: Microsoft.Office.Interop.Excel

Code:

4 Comments

  1. Jeroen Ritmeijer Says: 22-05-2014 09:15

    You know I am biased, but don’t build production systems based on this, you are in for a world of hurt.

    Good for one-offs though, providing you keep the bulk small and keep a good eye on the results.

    Reply this comment
    • Stefan Feenstra Says: 22-05-2014 09:32

      It’s indeed not something that you would like to use on a large scale production environment. But if you are in need of a onetime solution to convert a bulk of documents this could be a solution. And always make sure you test the results afterwards and make a backup of the original Office documents.

      Reply this comment
  2. Zuhal Kılıçaslan Says: 20-10-2016 10:50

    Thank you so much!!

    Reply this comment
  3. Sinethemba Says: 28-02-2017 10:14

    You are a genius Stefan. It works like a charm. Thank you

    Reply this comment

Post a Comment

Your email address will not be published. Required fields are marked *

*