PDA

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



mrezza
10-26-2015, 10:08 AM
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.

gmayor
10-27-2015, 02:13 AM
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.

mrezza
10-27-2015, 06:19 AM
Thank you. I deleted macro and made a new macro. Now macro runs without error.