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):
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