Scripting Microsoft Word

I created a script that runs through a premade document that replaces and occurances of “+[]+” with text stored in a variable. It works the problem is it does not continue to run unless I move the mouse around. Any ideas below is some code. Using Word 04

set chTab to ASCII character 8
set replaceText to lvivariable
set lastMark to 1 --to get count of string to each “^”
set currentReplace to “”
set partialReplace to “” --To hold text for each cell

–Get all of replacement text before “^” in lviVariable
repeat until lastMark > (length of replaceText)
set nextVar to “”
set testString to character lastMark in replaceText

 --If "^" is found then find where to put contents of variable 	     
 if contents of testString = "^" then
      set chSearchRange to front document
      select chSearchRange
      set searchVar to find object of selection
					
      --Search for and replace with variable contents in the main 
      tell searchVar
clear formatting
clear formatting
set format to false
set content to "+[]+"
set wrap to find stop
set match case to false
set match wildcards to false
set forward to true
execute find
      end tell
					
      set replaceRange to create range active document start (start of content of text object of selection) end (end of content of text object of selection)
					
      -------------If var is in table--------------------------------  
      if contents of currentReplace contains chTab then
--Initialize variables 
set partialReplace to ""
set tabMark to 1
						
--Get all of replacement text  before tab in currentReplace              
repeat until tabMark > (length of currentReplace)
							
                   set tabTextChar to character tabMark in currentReplace
							
       --If tab is found then find where to put contents of variable   
                   if contents of tabTextChar = chTab then
								
            set content of replaceRange to partialReplace						
            do Visual Basic "Selection.MoveRight (12)"
								
            set replaceRange to create range active document start (start of content of text object of selection) end (end of content of text object of selection)
            if content of replaceRange contains "+[]+" then
	set nextVar to "+[]+"
            end if
								
            --If we replaced the last of table text then end repeat 
            if tabMark = length of currentReplace then
                 exit repeat
            end if
								
           --Drop data inserted 
           set currentReplace to (characters (tabMark + 1) thru (length of currentReplace) of currentReplace) as string
								
          --Reinitialize variables 
          set partialReplace to ""
          set tabMark to 1
          --Else if tab was not found then 
          else
	-- increment tabMark and add character to string 
	set partialReplace to partialReplace & tabTextChar
	set tabMark to tabMark + 1
          end if
							
        end repeat

if contents of currentReplace does not contain chTab then
set content of replaceRange to currentReplace
if nextVar is equal to “+[]+” then
do Visual Basic “Selection.MoveRight (12)”
set replaceRange to create range active document start (start of content of text object of selection) end (end of content of text object of selection)
set content of replaceRange to nextVar
end if
else
if nextVar is equal to “+[]+” then
do Visual Basic “Selection.MoveRight (12)”
set replaceRange to create range active document start (start of content of text object of selection) end (end of content of text object of selection)
set content of replaceRange to nextVar
end if
end if
–If we replaced the last of doc the end repeat
if lastMark = length of replaceText then
exit repeat
end if

–Drop data inserted
set replaceText to (characters (lastMark + 1) thru (length of replaceText) of replaceText) as string

–Reinitialize variables
set currentReplace to “”
set lastMark to 1

--------------end if var is in table--------------------------

else
set content of replaceRange to currentReplace

–If we replaced the last of doc the end repeat
if lastMark = length of replaceText then
exit repeat

end if --Drop data inserted
set replaceText to (characters (lastMark + 1) thru (length of replaceText) of replaceText) as string

–Reinitialize variables
set currentReplace to “”
set lastMark to 1
end if

 --If "^" was not found then 
 else
      -- increment lastMark and add character to string 
      set currentReplace to currentReplace & testString
      set lastMark to lastMark + 1
 end if

end repeat