cancel
Showing results for 
Search instead for 
Did you mean: 

Storing a string in word document in bold text and in underline text

kshitijkumar
Level 3
Hi all, Can anyone suggest me how to write a string in bold format in word document and how to underline a specific text in word document.   Thanks & Regards, kshitij kumar.  
5 REPLIES 5

david.l.morris
Level 15
I don't ever use it, but it looks like you can use the MS Word VBO action 'Replace Highlighted Text' in order to bold text. You basically just replace the text with the same text but give a True value to 'new bold'. I don't see any existing action that will underline text. Probably the better way to do this is to take the code stage inside of 'Replace Highlighted Text', create your own object/action, add in what inputs you want, etc. For example, I imagine the code 'r.Bold=new_bold' from the Replace Hightlighted Text code stage can be adapted for underline. Probably need to check the Microsoft docs, but I bet 'r.Underline=True' or maybe 'r.Underline=1' will work. Of course, you'd want to take that True/1 as an input.

Dave Morris, 3Ci at Southern Company

kshitijkumar
Level 3
Hi , I have a word document which has some text written into it . i want to change few texts to bold . i have used 'Replace Highlighted Text' but it is asking for one input 'current highlight'. but don't know what to give. I also tried by giving blank value. but not able to highlight required text in my word.   Is there any way to highlight few texts while writing the text using  'Type Text' .     Thanks, kshitij

david.l.morris
Level 15
In this case, the word 'highlight' means to highlight the text with background color. If you're going to use that action, you'd put the number that correlates to the highlighted color. For example, I think 7 is yellow. Your text would need to be already highlighted with that color. Then your inputs could set the text to bold and remove the highlighting. Your inputs might look something like this... (the 7 assumes your text is highlighted in yellow and 0 removes the highlighting) handle: [handle] document name: [document name] current text: [text to search for] current highlight: 7 new text: [text to search for] new highlight: 0 new bold: True   Numbers to Highlighting colors: https://word.tips.net/T000253_Changing_Character_Color.html Some example code: https://docs.microsoft.com/en-us/office/vba/word/concepts/customizing-w…   You're better off just looking up some code online and copying it. Then you can create your own action that doesn't rely on highlighting. I dunno, maybe that's just a thing. Pretty weird, if you ask me.

Dave Morris, 3Ci at Southern Company

kshitijkumar
Level 3
i check with the activity but it is not working could you try at your end and let me know. anyway i am writing macro in word for doing these things.     Thanks

david.l.morris
Level 15
Yeah, what I said above was something I already tried in Word and it works for me. But anyway, you're probably better off with a macro. However, consider putting that same code inside a BP object so that it can be reused rather than in a macro in Word which will only be useful in that one document.

Dave Morris, 3Ci at Southern Company