Office Developer Center > Microsoft Office for Developers Forums > Word for Developers > vb macro from word 2003 does not run in word 2010

Unanswered vb macro from word 2003 does not run in word 2010

  • Thursday, February 23, 2012 3:22 AM
     
     

    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.Extend
       Selection.Find.Text = "<U>"
       Selection.Find.Execute

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

       

All Replies

  • Sunday, February 26, 2012 9:40 PM
     
     

    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"