Uipath pass data from excel to word

Hello all,

I m trying to pass data from excel to word using word application scope, excel application scope and replace text in document activity. I m first trying to save the original file to other name and then replace words and the save as pdf. However when the words are getting replaced they are moving below which is changing the original formatting. I need the words to stay at the original place as its very important. Any idea on how i can retain the original formatting?

Would appreciate your assistance

@mihir.s.bandodkar

Depending on the size of the words the appearance might change…can you please show some examples

Also in replace please use .Trim for any word you insert to make sure any extra spaces before and after are removed

Cheers

Hi @mihir.s.bandodkar

To retain the original formatting when replacing words in a Word document using UiPath, you can follow these steps:

  1. Use the “Word Application Scope” activity to open the Word document.
  • Provide the path of the Word document that you want to work with.
  • Save the output of the activity into a variable, let’s call it wordApp.
  1. Use the “Excel Application Scope” activity to open the Excel file containing the data you want to pass to the Word document.
  • Provide the path of the Excel file.
  • Save the output of the activity into a variable, let’s call it excelApp.
  1. Inside the “Excel Application Scope” activity, use the “Read Range” activity to read the data from the Excel file.
  • Specify the range or sheet from which you want to read the data.
  • Save the output to a variable, let’s call it excelData, of type DataTable.
  1. Outside the “Excel Application Scope” activity, use a “For Each Row” activity to iterate through each row in excelData.
  • Set the “TypeArgument” property to DataRow.
  • Use an appropriate variable, let’s call it row, to represent each row.
  1. Inside the “For Each Row” loop, use the “Replace Text in Document” activity to replace the desired words in the Word document.
  • Configure the activity to replace the target words with the corresponding values from the current row in excelData.
  • Specify the range or document part where you want to perform the replacement.
  1. After the “For Each Row” loop, use the “Save As PDF” activity to save the modified Word document as a PDF file.
  • Specify the output path for the PDF file.

Thanks!!

I m using the same workflow however its still moving down…