01-08-24 06:53 AM
Hi all,
i have written a table in ms word now i want change some text colour to red or green
example in below table i want to change colour
need solution how to achieve.
01-08-24 08:34 AM
Dear @Rama_krishna
Could you please create a custom code with the below in the MS Word VBO
Sub ChangeTextColor()
Dim doc As Document
Dim rng As Range
' Set the document object
Set doc = ThisDocument
' Change "www" text color to red
Set rng = doc.Content
With rng.Find
.Text = "www"
.Replacement.Text = "www"
.Replacement.Font.Color = wdColorRed
.Execute Replace:=wdReplaceAll
End With
' Change "yyy" text color to green
Set rng = doc.Content
With rng.Find
.Text = "yyy"
.Replacement.Text = "yyy"
.Replacement.Font.Color = wdColorGreen
.Execute Replace:=wdReplaceAll
End With
End Sub
Could you please implement the above and let me know the results.
02-08-24 10:36 AM
I'd probably just say that rather than amending the official MS Word VBO, best practice is to create a separate VBO with any new actions (plus the connect/attach actions so you can use it). Not amending the official word VBO will make it easer to take newer versions of it in future.
05-08-24 06:38 AM
Hi @faheemsd below error i am getting
'Let' and 'Set' assignment statements are no longer supported.
17-08-24 10:08 PM
Dear @Rama_krishna
I apologies for the delay in responding; my project work kept me quite busy.
I have made the code so simple that you may use any color to apply it to any text that is included in the Word document.
Input Parameters:
handle
document name
textTocolor
colorNumber
Code used in Code stage
' Find and replace text color
Dim d As Object = GetDocument(handle,document_name)
Dim r As Object = d.Range
' Execute find and replace
Do While r.Find.Execute(textTocolor)
r.Font.Color = colorNumber ' wdColorRed
r.Start = r.End
Loop
' Release objects
r = Nothing
for your requirement
red color number= 225
Green color number = 5287936
This is how we can achieve adding the colors to the required text in Word Document using Blue Prism
Please let me know if you face any difficulties Implementing the above steps.
@Michael_S All Blue Prism users will find this code useful in changing the text color in Word documents.