vb macro from word 2003 does not run in word 2010 RRS feed

  • Question

  • i got a piece of vba code from other people. It worked fine in Word 2003 and even worked in word 2007, but stopped working in word 2010.

    This piece of code was used to format some texts in word. It find the words between two  <u> and underline the words, then <u> are deleted. However in word 2010, it deletes both the words and two <u>.  The problem seems to be the following: when the second <u> is found, the words before <u> is also selected/highlight. so when Word is asked to delete <u> the words before it is deleted too. This was not a problem in word 2007. Wonder if vba has changed from word 2007 to 2010.  Please help!. Thank you very much.

    Here is an example of text i like to forma.

    <u>summary<u>                <u>percent<u>       <u>sum<u>    <u>total<u>

    'Fixing Underline <U>
    Selection.HomeKey Unit:=wdStory

    While (OutSub = 0)
       WordBasic.EditFind Find:="<U>"
       If WordBasic.editfindfound() = False Then GoTo OutUnderline
       Selection.Delete Unit:=wdCharacter, Count:=1
       Selection.Find.Text = "<U>"

       Selection.Font.Underline = True
       Selection.MoveUp Unit:=wdLine, Count:=1
       Selection.Find.Text = "<U>"
       Selection.Delete Unit:=wdCharacter, Count:=1
    If LargeFile = vbYes Then ActiveDocument.Save

    • Moved by Max Meng Friday, February 24, 2012 2:15 AM Moving to a more appropriate forum (From:Office 2010 Application Compatibility)
    • Moved by danishani Sunday, February 26, 2012 9:38 PM Word experts needed (From:Visual Basic for Applications (VBA))
    Thursday, February 23, 2012 3:22 AM

All replies

  • Dear lzcdc,

    I moved your thread to the Word for Developers Forum in the hope you get better response from Word Experts.

    Sorry for the inconvenience caused, best of luck! :)

    Best regards,

    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Sunday, February 26, 2012 9:40 PM