+ Reply to Thread
Results 1 to 4 of 4

Macro for word font colour

  1. #1
    Registered User
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    300

    Macro for word font colour

    Hi Guys,

    I need a macro that goes through every line within a word document.

    when it hits font with a particular colour, it needs to insert a line with text, then searching down the document, until it meets a second colour and then also insert a line with text, and repeat.

    The document contains any type of fonts, but only about 4 or 5 colours. I am only interested in having a line inserted for the first change of occurance of each particular colours.

    eg (for Blue and Red):
    wfefd wefs
    efwd wad
    sefd wd a
    esfsefd waa wd
    sefww dw
    ewqd ddsf
    esfd wdd
    sef ww dad sa
    sefdwd adwd ad a


    would become:
    efwd wad
    sefd wd a
    esfsefd waa wd
    sefww dw
    ewqd ddsf
    esfd wdd
    sef ww dad sa
    sefdwd adwd ad a
    Thanks,

    JimmyWilliams

  2. #2
    Registered User
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    300

    Re: Macro for word font colour

    *Bumping this thread.*

  3. #3
    Registered User
    Join Date
    04-02-2017
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    300

    Re: Macro for word font colour

    Hi Guys,

    I need a macro that goes through every line within a word document.

    when it hits font with a particular colour, it needs to insert a line with text, then searching down the document, until it meets a second colour and then also insert a line with text, and repeat.

    The document contains any type of fonts, but only about 4 or 5 colours. I am only interested in having a line inserted for the first change of occurance of each particular colours.

    eg (for Blue and Red):
    wfefd wefs
    efwd wad
    sefd wd a

    esfsefd waa wd
    sefww dw
    ewqd ddsf
    esfd wdd
    wadwad
    sef ww dad sa
    sefdwd adwd ad a
    redwda
    sefdwd adwd ad a
    sefdwd adwd ad a

    wfefd wefs
    sefdwd adwd ad a
    esfd wdd
    wfefd wefs
    wadwad

    would become:
    wfefd wefs
    Blue:
    efwd wad
    sefd wd a

    esfsefd waa wd
    sefww dw
    ewqd ddsf
    Red:
    esfd wdd
    wadwad
    sef ww dad sa
    Blue:
    sefdwd adwd ad a
    Red:
    redwda
    Blue:
    sefdwd adwd ad a
    sefdwd adwd ad a
    wfefd wefs
    sefdwd adwd ad a
    Red:
    esfd wdd
    wfefd wefs
    wadwad


    I hope that makes sense!
    Ideally I would like to be able to select what the two colours are, and also be able to customise the text inserted before each colour (eg "Red:" could be "Username A:" or "Serial NumberXXXX:")
    Last edited by JimmyWilliams; 07-08-2018 at 09:02 AM. Reason: This Post was added to make everything more clear.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    2,700

    Re: Macro for word font colour

    You could use a macro like:
    Please Login or Register  to view this content.
    Note: The inserted text is the same colour as the found text. You can replace the colour names in StrTxt with your preferred strings, but all 17 'positions' in StrTxt must be filled regardless of whether there is a corresponding ColorIndex reference in the Select Case test. A slightly different approach would be required to have the inserted text in a different colour from the found text.
    Last edited by macropod; 07-09-2018 at 09:18 PM.
    Cheers,
    Paul Edstein
    [MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1