Runtime Error in Word 2003

M

Misha

When I open Word 2003 I get this message:
Runtime error'91'
Object Variable or With Block variable not set
When I press Debug, this is the macro which is giving trouble:
Sub MAIN()
'
' AutoExec.MAIN Macro
' Executes when Word for Windows is loaded.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceAfter = 12
End With
With Selection.Find
.Text = "^p^p"
.Replacement.Text = " ^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

End Sub

The first line, Selection.Find.ClearFormatting, is highligted in yellow.
This started happening only this morning. I am not familiar with the macro
language and have no idea how to fix it. Help, please!
Thanks
 
B

Beth Melton

Do you really *need* the macro? Did you create it?

It's finding all occurrences of two paragraph marks in sequence and
replacing with one.

I don't why it is necessary to run when Word starts considering you
typically start with a blank document anyway....

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top