I have a document which is autogenerated. Each part of the document has a description and then a list of sentences that are listed as different list items. This works perfectly.
However, there is a need to change the style of certain words that are part of a dictionary, and which may appear anywhere in the text. Given that the dictionary is stored in database, this cannot be hardcoded. The solution is therefore to replace the style of the different words by means of Range.Find.
This solution works perfectly when the words are embedded in a sentence, but changes the bullet style when the word in question is at the beginning of a bulleted sentence.
- DictionaryWord that should be bolded in a list item
becomes
DictionaryWord that should be bolded in a list item
However,
- This DictionayWord is however bolded correctly without removing the "list" style
I have tried to enter a dummy text before the first word, and then delete it by means of anothe Range.Find, but the issue remains the moment I delete the dummy text.
The code for changing the dictionary words is as follows:
Set oRange = oDoc.Content
With oRange.Find
.Replacement.ClearFormatting
.Format = True
.Forward = True
.MatchCase = True
.MatchWholeWord = True
.Wrap = wdFindContinue
Set rsdictionary = DB.OpenRecordset("qrydictionaryterms", dbOpenSnapshot)
.Replacement.Style = "Dictionary Style"
While Not rsdictionary .EOF
.Execute findtext:=rsdictionary ("CDMStereotype"), MatchCase:=True, Replace:=wdReplaceAll
rsdictionary .MoveNext
Wend
end with
I would greatly appreciate any suggestions about how to fix this.