Using VBA with Word, I am writing a program that displays or hides certain letters and words in a document. To make the document more elegant, I set its background colour to “Parchment.” To highlight certain words by revising their character style to use shading, one of the options in Borders and Shading. I can change the display by changing the character style of the words with code such as this to revise my self-defined “Mont TC delete” character style:
t TC delete").Font
.Color = 5287936
.Texture = wdTexture20Percent
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = -687800423
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
.Borders.Shadow = True
The attached document shows some examples. It shows the word “faire” highlighted with a border and shading added through VBA. It also shows the words “savoir aussi” that at one point were highlighted like “faire” but now should blend in with the other words and be invisible.
My problem is the background around “savoir aussi”. It should match the parchment colour of the document, but, instead, it displays a clear white background. I can manually get rid of the white background by selecting those words and then by pressing Ctrl + Space. My problem is how to do that by using VBA to revise the properties of their character style.
The obvious simple solution is to forget about having a parchment background. That would be a pity, since the text is so much easier to read with the appropriate background.
What can I do?