Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Declaring an array of highlight colors (Word 2003)

    I do a lot of highlighting in Word. I'd like to set up some code that automatically cycles through four specific highlight colors (wdYellow, wdBrightGreen, wdTurqoise, and wdGray25) so that no two consecutive highlights are the same color. (I chose these four colors because they're light enough that the black text they highlight doesn't get lost.)

    My basic question is this: If I'm going to declare an array that holds these four color names, what data type should I use?
    I tried "Dim HColor(3) As String," but that didn't work.

    Eventually, I need the line
    Selection.Range.HighlightColorIndex = HColor(HltNo)
    where HltNo is an integer between 0 and 3.

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Declaring an array of highlight colors (Word 2003)


  3. #3
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Declaring an array of highlight colors (Word 2003)

    That seems to have worked.

    For future reference, the other problem I had was that, because I originally tried to populate my array with strings, I surrounded the color names in quotation marks. After I declared it as long, it didn't work until I removed the quotation marks.

    Thanks.

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Declaring an array of highlight colors (Word 2003)

    OK, the thing to remember here is that all of those built-in constants (wdWhatever) are in fact variable names (constant names actually) which carry some sort of preassigned value of a particular type (Long, Double etc.) You use them just the same way as you use your own variables, declared to be of a particular type. For example:
    <code>
    Me.Label1.BackColor = 10092543
    Me.Label1.BackColor = wdColorLightYellow
    Me.Label1.BackColor = RGB(255, 255, 153)
    </code>
    are all equivalent. You can find the values of all the built-in constants somewhere in the Help files.

    Alan

Posting Permissions

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