Consulting

Results 1 to 2 of 2

Thread: Changing font color of a bookmark in VBA

  1. #1

    Changing font color of a bookmark in VBA

    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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Set bmClassification = ActiveDocument.Bookmarks("Classification").Range 
    bmClassification.Text = "CONFIDENTIAL" 
    bmClassification.Font.Color = RGB(237, 28, 36)
    ActiveDocument.Bookmarks.Add "Classification", bmClassification
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •