Consulting

Results 1 to 6 of 6

Thread: Finding past perfect

  1. #1

    Finding past perfect

    I'm working on a macro that would find any form of "had V-ed" and replace them with a Vietnamese equivalence. The macro itself is just a simple find & replace command, tested with some other queries and worked like a charm.

    The problem is I can never seem to figure out an expression to track the past perfect form. Currently, I'm using the following wildcard expression:
    had (<[A-z]{1,}ed>)
    It never found anything. Did I make a mistake somewhere?

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    What specific word or words are you trying to find?
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Anything that ends with an "ed" and is preceded by the word "had" (ie. "had joked", "had showered", "had paused",...)

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Sub ScratcMacro()
    'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 9/1/2017
    Dim oRng As Word.Range
    Set oRng = ActiveDocument.Range
      With oRng.Find
        .Text = "had *ed>"
        .MatchWildcards = True
        While .Execute
          oRng.Select
          oRng.Collapse wdCollapseEnd
        Wend
      End With
    lbl_Exit:
      Exit Sub
    End Sub
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    3.jpg
    I test searched the query, and this happen. Apparently, "*" is not limited to just 1 word.

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by vkhu View Post
    I'm working on a macro that would find any form of "had V-ed" and replace them with a Vietnamese equivalence. ... The problem is I can never seem to figure out an expression to track the past perfect form.
    Quote Originally Posted by vkhu View Post
    Anything that ends with an "ed" and is preceded by the word "had" (ie. "had joked", "had showered", "had paused",...)
    Do note the past perfect form can include other words between the had and the word ending in 'ed'. The Find expression in Greg's macro will find multi-word strings of any length starting with 'had' until it encounters a word ending in 'ed'. Accordingly, it will find past perfect forms that include intervening words - which is a good thing - but it's also liable to make some false matches (e.g. I once had a car that was loud. It was also fast - which is what you'd expect because it was red). If you want to limit the Finds to word pairs, try:
    Find = had <[! ]@ed>
    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
  •