R
Roger Marrs
Using the code below in Word 2000 a macro I was using worked just fine.
After upgrading to Word 2003 it no longer works correctly. In fact if I
execute the macro on a table with more than one row in it, the screen just
starts flashing and I have to halt Word with the task manager.
Here's the 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
Here's what I see happening when I execute that code:
Example, I have a table with two rows, both of which are highlighted:
2136
2130
The macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }then (I think) it selects
2130 but replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/ .doc B }
and then the screen just keeps flashing requiring me to open the task
manager and end Word.
If I have a single row table, such as:
2136
Then the macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }
and then ends normally, instead of going into a continuous loop. However,
that results in a filename error because the macro is inserting a " " (blank
space) between the filename and the .doc extention.
Any suggestions or assistance correcting this problem would be greatly
appreciated.
Thanks,
Roger
After upgrading to Word 2003 it no longer works correctly. In fact if I
execute the macro on a table with more than one row in it, the screen just
starts flashing and I have to halt Word with the task manager.
Here's the 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
Here's what I see happening when I execute that code:
Example, I have a table with two rows, both of which are highlighted:
2136
2130
The macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }then (I think) it selects
2130 but replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/ .doc B }
and then the screen just keeps flashing requiring me to open the task
manager and end Word.
If I have a single row table, such as:
2136
Then the macro selects 2136 and replaces it with:
{INCLUDETEXT I:/htltr/jdltr/prod/2136 .doc B2136 }
and then ends normally, instead of going into a continuous loop. However,
that results in a filename error because the macro is inserting a " " (blank
space) between the filename and the .doc extention.
Any suggestions or assistance correcting this problem would be greatly
appreciated.
Thanks,
Roger