Skip to main content
Question

Copy/paste from Word documents preserving formatting


Forum|alt.badge.img+4

I have an original Word document which contains a table with two columns. I need to copy the contents of the second column. The second column has text which is formatted a particular way (some text in bold, line breaks, bullet points).

I need to paste this into a separate Word document with a similar but differently formatted table.

I’ve tested what the workflow would look like myself - copy the text, paste in the new document in the correct place. In order to locate where the text will be copied and pasted, I’ll use simulate keystrokes - [Tab]. 

However, it would be easier to save to variables and then paste them at the end. Can I do this whilst preserving formatting?

6 replies

Lu.Hunnicutt
Pathfinder Community Team
Forum|alt.badge.img+10
  • Pathfinder Community Team
  • 45 replies
  • March 13, 2025

Hi! Let me tag some folks who may be able to support you with this.

@Olatidoye 

@SakthiVel 

@ChanduMohammad 

@GOAA 


Forum|alt.badge.img+4

@Aaron.Gleason, could you can advise please?


Forum|alt.badge.img+4
  • Navigator | Tier 3
  • 19 replies
  • March 14, 2025

hello @thomas.gawda,

The difficulty you're experiencing is with copying or formatting.Can you please send us an image of your code?

 


Forum|alt.badge.img+4
Olatidoye wrote:

hello @thomas.gawda,

The difficulty you're experiencing is with copying or formatting.Can you please send us an image of your code?

 

Can variables preserve formatting of rich text? That would make my workflow easier as I can first extract the text and save as variables, and then populate the second document. Otherwise I would have to go between the documents which may be more brittle/prone to error.

Open to other suggestions as to the workflow.


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 503 replies
  • March 14, 2025

Two things that might help you:

Check out String: Evaluate variable. It lets you create a string with variables and resolve it all to a single string. 

Consider using our clipboard functionality to copy the string from above to the clipboard. Then, in Word, use the paste special keyboard shortcut to paste into the area you want. 

Working with Word is challenging because it is not (necessarily) structured. You can also consider putting some markers in place and using the Find/Replace functionality of Word itself to help. 


Forum|alt.badge.img+4
Aaron.Gleason wrote:

Two things that might help you:

Check out String: Evaluate variable. It lets you create a string with variables and resolve it all to a single string. 

Consider using our clipboard functionality to copy the string from above to the clipboard. Then, in Word, use the paste special keyboard shortcut to paste into the area you want. 

Working with Word is challenging because it is not (necessarily) structured. You can also consider putting some markers in place and using the Find/Replace functionality of Word itself to help. 

I’ve tried using the clipboard functionality but when I assign clipboard to string, it loses the formatting (bold, bullet points, line breaks). It seems like my only way forward is to copy to clipboard and paste for each table row.

Unfortunately find and replace does not support formatted text (as far as I can see). Seems like I will have to stick with Simulate keystrokes, unless there is another way to find and replace the text?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings