Re: Macro misfires after move to Word 2003 by Roger
Roger
Mon Jun 28 15:20:59 CDT 2004
I assume it's the "Do While" routine.
Here's what I'm seeing.
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.
Hopefully that make my problem easier to diagnose. Sorry I wasn't more
detailed with me first message. It was a really bad week.
"DA" <infoscene@nospam.winshop.com.au> wrote in message
news:2105101c45a50$309d8690$a301280a@phx.gbl...
> When you say it's getting stuck in a loop, do you mean
> your "Do While" routine?
>
> If that's the case, what is it finding in the doc? Since
> you're using the selection property you should clearly
> see in your doc what is happening.
>
> Dennis
>
> >-----Original Message-----
> >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
> >
> >
> >.
> >