Hi @Alearns ,
Could you try to use the below Code Snippet in Invoke Code
Activity (Language set to CSharp)
try
{
var wordApplication = new Microsoft.Office.Interop.Word.Application() { Visible = false };
var myDocument = wordApplication.Documents.Open(in_FilePath);
foreach(string word in in_WordsToColor)
{
Microsoft.Office.Interop.Word.Find find = myDocument.Content.Find;
find.Execute(word);
if (find.Found)
{
Microsoft.Office.Interop.Word.Range range =(Microsoft.Office.Interop.Word.Range) find.Parent;
range.Select();
myDocument.Application.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed;
}
}
myDocument.Save();
wordApplication.Quit();
}
catch( Exception e)
{
Console.WriteLine(e.Source.ToString()+" "+e.Message.ToString()+" "+e.TargetSite.ToString());
}
Here, we would need to pass two arguments to Invoke Code Activity, in_FilePath
which should be the file path of the Word Document and in_WordsToColor
, an Array of String type which should contain the array/list of words that you would want to color.
Let us know if you are facing issues in performing the above.