R
Roger Marrs
I was using the code below on a Win 98 machine running Word 2000. It worked
fine. I am now trying to run the same code on a Win XP Pro machine running
Word 2003. The macro seems to insert all the includetext fields just fine,
but instead of ending after the last insert, it goes into a continuous loop.
Code:
Dim marker As String
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
Do While .Execute(FindText:="", _
Wrap:=wdFindStop, Forward:=True) = True
marker = Selection.Text
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
_
PreserveFormatting:=False
Selection.TypeText Text:="INCLUDETEXT " & Chr(34) &
"I:/htltr/jdltr/prod/" & marker & ".doc" & Chr(34) & " B" & marker
Selection.MoveRight wdCharacter, 2
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
Loop
End With
ActiveDocument.Fields.Update
fine. I am now trying to run the same code on a Win XP Pro machine running
Word 2003. The macro seems to insert all the includetext fields just fine,
but instead of ending after the last insert, it goes into a continuous loop.
Code:
Dim marker As String
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
With Selection.Find
Do While .Execute(FindText:="", _
Wrap:=wdFindStop, Forward:=True) = True
marker = Selection.Text
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
_
PreserveFormatting:=False
Selection.TypeText Text:="INCLUDETEXT " & Chr(34) &
"I:/htltr/jdltr/prod/" & marker & ".doc" & Chr(34) & " B" & marker
Selection.MoveRight wdCharacter, 2
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = Not
ActiveWindow.View.ShowFieldCodes
Loop
End With
ActiveDocument.Fields.Update