Hi!
Sorry if this is an "amateur" question: i've used VBA in Excel fairly extensively, but not much in Word.
Im using MSOffice 2010.
I have a template document with (working) code in it, which asks the User for various details. These details are processed and stored in a dynamic array, until the User indicates that the "data gathering" has completed.
At this point I want to write the array to the end of the document, with each element of the array being a "sentence". This bit is working.
Extracts from the code are shown below
Code:
Dim intMax As Integer
Dim intPtr As Integer
Dim strDate As String
Dim strCategory As String
Dim strHdr As String
Dim strOldCategory As String
Dim strText As String
strOldCategory = ""
With ActiveDocument.Content
.InsertAfter vbCrLf
intMax = UBound(gvarTexts)
'*
'** Add texts, with formatting if appropriate.
'*
For intPtr = 0 To intMax
strCategory = Left(gvarTexts(intPtr), 20)
strDate = Mid(gvarTexts(intPtr), 22, 10)
strText = Mid(gvarTexts(intPtr), 33)
If strCategory <> strOldCategory Then
strOldCategory = strCategory
strHdr = strCategory & ":" & strDate
.InsertAfter vbCrLf & strHdr & vbCrLf
'*
'** Here something magic needs to happen to change strHdr
'** which has just been written to be Bold and Underlined!
'*
End If
.InsertAfter strText & vbCrLf
Next intPtr
In essence, the first part of each array string is a "Category". When the Category changes I want to write the new Category in Bold and Underlined, then continue writing the texts which match that Category in the normal way (i.e. not bold or underlined).
I think it needs to happen around the area marked "Here something magic" etc.
Can any kind soul point me in the right direction?