Select text of a particular shading color (VBA macro)

Joined
Feb 6, 2017
Messages
5
Reaction score
0
Hello everyone,

I am trying to use a macro to select text of particular shading in word ( I later want to change that shading and highlight it rather).

I are having trouble in selecting text of a particular shading color.

Using

char.Font.Shading.BackgroundPatternColor <> wdColorAutomatic

works, selecting characters of any shading other than automatic, but using

char.Font.Shading.BackgroundPatternColor = wdColorYellow

does not work. I want to be able to select text with a particular shading color. Any ideas as to why this isn't working or what might work rather?

Thanks
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
You need to be clear about whether you're working with a font's shading or its colour - the two are entirely different. A red font, for example, can ordinarily be expected to have a .Shading.BackgroundPatternColor = 0 (wdAuto), but a .ColorIndex = 6 (wdRed). Shading would typically give the font a coloured background without changing its colour.

Using .Font.Shading.BackgroundPatternColor = wdColorYellow to shade a designated character or range works for me.
 
Joined
Feb 6, 2017
Messages
5
Reaction score
0
Hi @macropod

I am working with the font shading color. I am clear about that.

I am able to change the shade of a designated character or range to desired color; BUT I am not able to "select/find" character/range with a particular shade.

Thanks,
Ananya
 

macropod

Microsoft MVP
Joined
Mar 2, 2012
Messages
578
Reaction score
50
Since you're collaborating with Gradtrainer, how about you just wait until his question is dealt with.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top