Convert Word Files into PDFs without using Word Application Scope (code not working)

I’m trying to use some custom code found in another thread to convert docx to PDF without Word installed on the machine. The code can be found here: Convert Word Files into PDFs without using Word Application Scope

When I run the code , the first line below fails to run:
Dim MyApp As New Microsoft.Office.Interop.Word.Application
and I get the following error:
Invoke code: Exception has been thrown by the target of an invocation.

I’ve already installed a Microsoft.Office.Interop.Word activity as suggested in some other threads and followed the guide HOWTO: Use MS Office COM interop with UiPath.

Any ideas on what could be going wrong please? See code and log/error message below:


To start with please run the bot in debug mode…then you can open the locals pane and check the inner exception detils which will contain more and exact information if what failed inside the invoke code


You still need Word installed.

“without Word Application Scope” isn’t the same as “without Word installed.” It just means they didn’t want to have to use the Word Application Scope activity to open each Word file. The code still requires Word to be installed, so the methods are available.

Ah I see, thanks for the info. I don’t suppose there are any other methods available for without Word installed that you know of?

There are web sites where you can upload a Word document and they’ll give you back a PDF. Not sure how bot-friendly they are.

You could probably also use a free document editor like Open Office to open the Word file and then save it as a PDF.

How come?
If word is not installed by opening document we cannot save the file as pdf
If we want to save pdf then we have to use word application scope to use word application scope Microsoft Office needs to install