locked
Macro text and number (with changing value) highlight RRS feed

  • Question

  • Hi there, someone kindly helped me previously to set up a macro to flag any instances of a word (the word being "inaudible") within a document and change the text colour to red.   

    I now require to instead of making the font colour red, change it to highlight the text to yellow.  I have managed to amend the macro created to do this. 

    Here it is as it stands with the highlight in yellow for the word "inaudible" 

    Sub FlagInaudibleYellow()

    With ActiveDocument.Range.Find

      .ClearFormatting

      .Text = "[Ii]naudible"

      With .Replacement

        .ClearFormatting

        .Highlight = yellow

        .Text = "^&"

      End With

      .Format = True

      .Forward = True

      .MatchWildcards = True

      .Wrap = wdFindContinue

      .Execute Replace:=wdReplaceAll

    End With

    End Sub

    However, a problem arises in that the time-coding also needs to be highlighted in yellow.  This is inserted by using our transcription software (hitting F1 and then Ctrl + V) and inserts a time-code into MS Word, e.g. 00:01:07 and so on at the point in which the obscured speech was heard. 

    Therefore, how can I set up the macro to also highlight the time-coding? 

    Anybody?! 

    Thanks, 

    FP 


    • Edited by Frecklepaw Friday, June 15, 2018 9:19 AM
    Friday, June 15, 2018 9:18 AM

Answers

  • .Highlight = yellow won't set the color to yellow. You can set .Highlight to True or False. If you set it to True, the macro will use whatever highlight color has already been set.

    The following macro will highlight both the word inaudible and time stamps in the document:

    Sub FlagInaudibleYellow()
    With ActiveDocument.Range.Find
      .ClearFormatting
      With .Replacement
        .ClearFormatting
        .Highlight = True
        .Text = "^&"
      End With
      .Format = True
      .Forward = True
      .MatchWildcards = True
      .Wrap = wdFindContinue
      .Text = "[Ii]naudible"
      .Execute Replace:=wdReplaceAll
      .Text = "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"
      .Execute Replace:=wdReplaceAll
    End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Frecklepaw Friday, June 15, 2018 12:18 PM
    Friday, June 15, 2018 12:04 PM

All replies

  • Is the time-stamp associated with the 'inaudible' string and, if so, what is their order and by what are they separated?

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, June 15, 2018 11:50 AM
  • .Highlight = yellow won't set the color to yellow. You can set .Highlight to True or False. If you set it to True, the macro will use whatever highlight color has already been set.

    The following macro will highlight both the word inaudible and time stamps in the document:

    Sub FlagInaudibleYellow()
    With ActiveDocument.Range.Find
      .ClearFormatting
      With .Replacement
        .ClearFormatting
        .Highlight = True
        .Text = "^&"
      End With
      .Format = True
      .Forward = True
      .MatchWildcards = True
      .Wrap = wdFindContinue
      .Text = "[Ii]naudible"
      .Execute Replace:=wdReplaceAll
      .Text = "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"
      .Execute Replace:=wdReplaceAll
    End With
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Frecklepaw Friday, June 15, 2018 12:18 PM
    Friday, June 15, 2018 12:04 PM
  • Amazing, works perfectly! Thanks so much :) 
    Friday, June 15, 2018 12:18 PM