Convert multiple .docx files to pdf

How do I convert multiple .docx files in a folder into pdfs of the same name and place it in another file location?


Hope the below steps would help you resolve this

  1. Use a assign activity like this

arr_files = Directory.GetFiles(“yourfolderpath”)

  1. Then use a FOR EACH activity where pass the above array variable as input and change the type argument as string

  2. Before getting inside the loop let’s install UiPath.Word.Activity

  3. Then inside the loop use a word application scope and pass the filepath as item.ToString

  4. Inside the scope use EXPORT TO PDF and mention the filepath like this

Path.GetDirectoryName(item.ToString)+”\”+ Path.GetFileNameWithoutExtension(item.ToString)+”.pdf”

Cheers @eoch

how do i fix this error?

Make sure the above expression is used


Arrfiles is a variable of type array of string

Cheers @eoch

hi sorry im not sure what you mean in step 4, what is pass filepath as item.tostring ?

In word application scope we must pass a filepath as input

In that property mention like this


Where item is the variable in for each loop


You may also consider using Invoke code for c#

Document doc = new Document(strFileName +".docx");
doc.Save(strFileName +".pdf") 

While strFileName is the argument passed to that choice

strFileName can be a path too but without extension at the end

Hi @eoch ,

you can try the “Save As” activity from BalaReva.Word.Activities. Here you can get the sample.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.