top of page

06. Bold, Italic, or Underlined Text


A work-around that allows you to use simple text formatting (bold, italics, underline) in a computation variable. For word processor-based documents only.


Microsoft Word macro code:

(kept in a template in the Office Startup
folder to make it globally available)

With Selection
' Set up common .Find properties
.Find.Forward = True
.Find.Wrap = wdFindStop
.Find.Replacement.Text = "" ' empty string
' Handle the underlining
.HomeKey unit:=wdStory
While .Find.Execute(FindText:="<U>", MatchCase:=False)
If .Find.Execute(FindText:="</U>", MatchCase:=False) Then
.MoveLeft unit:=wdCharacter, Count:=4 ' left of "</U>"
.Font.Underline = wdUnderlineSingle
.Collapse wdCollapseEnd
.Delete unit:=wdCharacter, Count:=4 ' delete "</U>"
End If
Wend ' While .Find.Execute()
End With


Insert HTML tags for underlining ("..."), bold ("..."), or italics ("..."), and then use a macro after assembly to search out the tags and actually apply the formatting. This macro is executed using a HotDocs "PLAY" instruction inserted at the end of the document.

I'll just sketch out underlining here--bold and italics are very similar. For underlining "tags" I chose to use the respective HTML commands to start and to end, but they could be anything. The text that needs to be underlined is surrounded by these tags, as follows:

SET TextVariable TO "This is underlined text"

The macros used to actually apply the formatting follow.

For Bolding and Italics, repeat this from ".HomeKey" to "Wend" (within the "With Selection" and "End With), looking for appropriate tags (I used and ) and setting ".Font.Bold = True" and ".Font.Italic = True".

bottom of page