How to trim the spaces in Word Document when replacing the text

@HarrisonJard, the replace activity is making things hard to work with, especially for what you are trying to do.

Instead, I used assign activity and I used something like this:

To replace strings:
WordText.Replace("<Requirement1>","Policy")
WordText.Replace("<Requirement3>",Nothing)

To Remove all blank newlines:
String.Join(Environment.Newline,WordText.Split(Environment.Newline.ToArray(),Stringsplitoptions.Removeemptyentries))

Here is an Example: Trim Spaces.xaml (8.8 KB)

1 Like