word vba stops & starts when moved to new pc?

dgr7

Board Regular
Joined
Apr 5, 2006
Messages
225
hello,
We have some Word VBA code that used to run fine in Word 2007. When I setup a new pc for the user and installed a new copy of Word 2007 on it, then moved the VBA code to that new pc, now I'm running into a strange problem where the code "stops and starts" (i.e. a MS VB Code Execution has been interrupted window appears) and you have to click Continue many times to get it to run the loop all the way through to it's logical end. This problem is not isolated to one specific VBA subroutine, it seems to happen in all of them on this new pc. Also, these subroutines still run fine on the old pc and also another pc in the office that has Word 2007 which I've tested them on.
Could someone please tell me how to fix this "stopping & starting" issue I'm having so it'll run properly like it did on the old pc. I'm assuming it's some setting in the options of Word 2007 that needs to be changed? Or is some application in the background interrupting the code exection?

thanks in advance,
david

below is the code I'm having trouble with at present. we use this code to add text in between a long list (hundreds-to-thousands) of account numbers that we cut and paste from an excel worksheet into word as unformatted text.
the line that it's stopping on (if I click Debug instead of Continue) and I have to then click Continue is
Loop Until (Selection.End = ActiveDocument.Content.End - 1):

Code:
Sub L996CLTACCTNO_new()
'
Selection.HomeKey Unit:=wdStory
    Do
    Selection.EndKey Unit:=wdLine
    Selection.TypeParagraph
    Selection.TypeText Text:="1"
    Selection.TypeParagraph
    Selection.TypeText Text:="L"
    Selection.TypeParagraph
    Selection.TypeText Text:="996"
    Selection.TypeParagraph
    Selection.TypeText Text:="Y"
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeText Text:="M"
    Selection.TypeParagraph
    'having the below MoveDown line is imporant for the Until to function properly
    Selection.MoveDown Unit:=wdLine, Count:=1
Loop Until (Selection.End = ActiveDocument.Content.End - 1)
    Selection.TypeBackspace
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeParagraph
    Selection.TypeText Text:="SYS"
    Selection.TypeParagraph
    Selection.HomeKey Unit:=wdStory
    Selection.TypeText Text:="I"
    Selection.TypeParagraph
    Selection.TypeParagraph
    'ActiveDocument.Save
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,225,360
Messages
6,184,508
Members
453,237
Latest member
lordleo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top