Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Code Won't Run in Footnotes (Word 2003) (Word 2003)

    I have some code that runs just fine on text, but it barfs on the footnotes. I see no reason why this should be occurring (other than maybe a memory error). I had a similar problem in 2002 and it turned out to be a bug caused by one of the security patches MS had put out.

    The specific line that it crashes on is "Selection.Find.Execute Replace:=wdReplaceAll"

    ---------
    Private Sub Replace(LookFor, ReplaceWith, wrp)
    On Error Resume Next
    Home
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = LookFor
    .Replacement.Text = ReplaceWith
    .Forward = True
    If wrp = 0 Then .wrap = wdFindStop
    If wrp = 1 Then .wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    End Sub
    --------------------------------------

    Thanks in advance for any help!

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Code Won't Run in Footnotes (Word 2003) (Word 2003)

    I'm still running 2002, so it's difficult to help, but I do have two thoughts:
    1. <LI>What do you get if you comment out On Error Resume Next? I.e., specific error number/description?

      <LI>Since there is a built-in Replace() function, it would be good to rename your procedure if you can.
    Hopefully someone with Word 2003 can help more.

  3. #3
    Star Lounger
    Join Date
    Nov 2003
    Posts
    61
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Re: Code Won't Run in Footnotes (Word 2003) (Word 2003)

    I get "Microsoft has encountered a problem and needs to close...." Then it asks me if I want to send an error report of MS.

  4. #4
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Jeddah, Saudi Arabia
    Posts
    243
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Code Won't Run in Footnotes (Word 2003) (Word 2003)

    I am using Word 2003. I ran your code and it works fine on my computer. The fact that you get a serious crash and not a VBA error leads me to believe that you have a problem with your Office installation.

    My suggestion would be to repair or re-install Office.

    Regards,
    Kevin Bell

Posting Permissions

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