Consulting

Results 1 to 3 of 3

Thread: Run-time error '424': Object Required in VBA word 2013

  1. #1

    Run-time error '424': Object Required in VBA word 2013

    Hi
    I got below macro code from answers.microsoft site, but it errors while running.

    Run-time error '424': Object Required
    The red line of code is causing this error.

    Sub ScratchMacro()
    'A basic Word macro coded by Greg Maxey
    Dim oRng As Word.Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
    .Text = "[0-9]{3,}"
    .MatchWildcards = True
    While .Execute
    oRng.Select
    If MsgBox("Do you want to format this instance", vbQuestion + vbYesNo, "FORMAT") = vbYes Then
    oRng = Format(oRng, "#,##0")
    End If
    oRng.Collapse wdCollapseEnd
    Wend
    End With
    End Sub

    Any idea?
    Best Regards.

  2. #2
    The macro works correctly in Word 2013. You could change the line to
    oRng.Collapse 0
    but there is no reason why its long form should error. However VBA errors can be cumulative so if the problem persists reboot the PC and try again.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Thank you. I deleted macro and made a new macro. Now macro runs without error.

Posting Permissions

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