Hi, I have a excel sheet from where in need to copy a data and paste it into a word document … After that I need to change the column width of the specific columns in word…
To copy data from an Excel sheet and paste it into a Word document, and then adjust the column width of specific columns in Word using UiPath, you can follow these steps:
Use the “Excel Application Scope” activity to open the Excel file and perform operations on it.
Use the “Read Range” activity to read the data from the Excel sheet and store it in a data table variable.
Use the “Word Application Scope” activity to open the Word document and perform operations on it.
Use the “For Each Row” activity to loop through each row in the data table.
Inside the loop, use the “Copy Selected Range” activity to copy the data from the Excel sheet.
Use the “Type Into” activity to simulate pressing “Ctrl + V” and paste the copied data into the Word document.
After pasting the data, use the “Table Column Width” activity to adjust the column width of specific columns in the Word document.
Specify the table in the Word document where you pasted the data.
Specify the column index or name that you want to adjust.
Set the desired width for the column.
Repeat steps 5 to 7 for each row in the data table.
Use the “Save” activity to save the changes made to the Word document.
Use the “Close Application” activity to close the Word application.
Here’s an example workflow in UiPath using the above steps:
Use the “Excel Application Scope” activity to open the Excel file.
Use the “Read Range” activity to read the data from the Excel sheet and store it in a data table variable, let’s say “excelData”.
Use the “Word Application Scope” activity to open the Word document.
Use the “For Each Row” activity to loop through each row in the “excelData” data table.
Inside the loop, use the “Copy Selected Range” activity and select the range of cells you want to copy from the Excel sheet.
Use the “Type Into” activity and send the “Ctrl + V” key combination to paste the copied data into the Word document.
Use the “Table Column Width” activity to adjust the column width in the Word document.
Set the “Table” property to the table where you pasted the data.
Specify the “ColumnIndex” or “ColumnName” to identify the column you want to adjust.
Set the desired “Width” value for the column.
Repeat steps 5 to 7 for each row in the “excelData” data table.
Use the “Save” activity to save the changes made to the Word document.
Use the “Close Application” activity to close the Word application.
Use the Insert datatable to document activity to write the datatable to the word file. It was autofit the range of columns according to the sentence in the rows. Don’t use any other activities to autofit.
I already checked in my machine. Check the below workflow.