How to change docx to pdf for current file in a for each file loop

how to use word application scope and save doc as pdf activities to change my current file in a each file loop to pdf.

@Helpmepls

Welcome to the community

Follow the steps

  1. For each file in folder and give the folder path
  2. Inside it use word application scope and pass currentfile.FullName
  3. Inside it use save document as pdf activity …with currentFile.FullName.replace(currentFile.Extension,".pdf")

This will ensure each file is saved with same name with .pdf extension

https://docs.uipath.com/activities/other/latest/productivity/word-export-to-pdf

Hope this helps

Cheers

Hey @Helpmepls ,

Welcome to the community

To convert word to Pdf there is a activity called as Save Document As PDF , u can get that activity by installing the UiPath.Word.Activities package in the Manage packages Panel

Below is the sample workflow to convert word to pdf

Word_TO_Pdf.zip (24.2 KB)

Hope it helps you out!

1 Like

Hi @Helpmepls

Hope this video will help you.

Hello @Helpmepls

For Each file in ListOfWordDocuments

Word Application Scope

    Input: file (the current Word document file path)
    
    Save Document as PDF
    
    Output: PathToPDF (specify the PDF file path and name)

Thanks & Cheers!!!

Hi

Try Follow steps
→ Use For each file in folder activity and provide path
→ Inside For each in folder activity use word application scope and pass currentfile.FullName
if the activity is not available please install UiPath.Word.Activities package
→ Inside it use save document as pdf activity …with currentFile.FullName.replace(currentFile.Extension,“.pdf”)

Thank you

@Helpmepls,
Welcome the the community

  1. Install the UiPath.Word.Activites package
  2. Store the path where the list of word files are stored in a string() variable.
  3. Use a For each loop for the path variable.
  4. Use word application scope for current file.
  5. Use Save document as pdf and provide the destination path.

1 Like

there is no error but it does not work

@Helpmepls

Can you please show what you tried

Did it go into loop? if not then the folder does not contain any files mostly

cheers

actually it works but it did not change the correct one, i have a for each file activity and it will change info in each docx but when i put this pdf changer into the do of the for each file it change the original but not the updated one with recent change info using the for each file activity

@Helpmepls

Can you please explain…dint understand what you you mean by changed original but not updated

May be we can resolve if you can show or explain more

Is updated file also in the same folder? if yes it should be modified to pdf

cheers

do u have email i email u the file


Now my Outputfilepath is the updated file, but it saved to another location, how could i save it to outputfilepath location instead? I tired using outputfilepath.fullname instead but i cant

Now my Outputfilepath is the updated file, but it saved to another location, how could i save it to outputfilepath location instead? I tired using outputfilepath.fullname instead but i cant


Now my Outputfilepath is the updated file, but it saved to another location, how could i save it to outputfilepath location instead? I tired using outputfilepath.fullname instead but i cant

@Helpmepls

You need to give currentfile.fullname in the work application scope…else for each loop it would open the same file which is present in outputfilepath…

Please check the steps given above

Hope this clarifies

And outputfilepath is what kind of data? Is it a word file location again?

And if you want to save output to a different location then use as below

Path.Combine("FolderLocationtosave",currentFile.Name.replace(currentFile.Extension,".pdf"))

Here in place of folderlocationToSave give the folder where you want to save …so that the pdf file gets saved in given folder witht he same name as input…but the word application scope still should be currentfile.Fullname…else only one file will be converted always

Hope this helps

Cheers

@Helpmepls

To save the updated file to the OutputFilePath location in UiPath, use the “Move File” activity. Set the “Source” to the path of the updated file and the “Destination” to the OutputFilePath variable. This moves the file to the desired location.

@Helpmepls ,

Maybe you would require to use the below Expression in File Path to Save As property :

OutputFilePath.Replace(OutputFilePath.Extension,".pdf")

it kept saying this
image

These are the process, how could i fix it the pdf to outputfilepath