PDA

View Full Version : [SOLVED:] Changing font color of a bookmark in VBA



Roderick
10-30-2017, 10:54 AM
I have a bookmark called Classification in the footer of a document.

The procedure to add it is below provided the text is monochrome and it works perfectly:

Set bmClassification = ActiveDocument.Bookmarks("Classification").Range
bmClassification.Text = "CONFIDENTIAL"
ActiveDocument.Bookmarks.Add "Classification", bmClassification

My next goal is to change its color and I've used the following:

Selection.Font.Color = RGB(237, 28, 36)

However, on doing this is opens a sub-window at the bottom of the screen with the footer in it indicating to me that there is a problem and Word is not happy.

I then tried:

Selection.Bookmarks("Classification").Range.Font.Color = RGB(237, 28, 36)

This time I got a VBA error.

What do I have to write, please, that will take the word (in this case CONFIDENTIAL) inside the bookmark and turn it into the desired RGB color?

I've read both Greg Maxey's and Graham Mayor's excellent articles on bookmarks but neither answers, in this case, my particular question.

Thanks for any help

macropod
10-30-2017, 12:59 PM
Set bmClassification = ActiveDocument.Bookmarks("Classification").Range
bmClassification.Text = "CONFIDENTIAL"
bmClassification.Font.Color = RGB(237, 28, 36)
ActiveDocument.Bookmarks.Add "Classification", bmClassification