Re: Insert Rows Above Found Text in Table by Chad
Chad
Wed Aug 04 10:53:55 CDT 2004
Glad I could help.
Regards,
Chad
"James Pannozzi" <jpannozzi@csi.com> wrote in message
news:epzXDmjeEHA.3984@TK2MSFTNGP10.phx.gbl...
> Thanks, that is a GREAT idea.
>
> I'm building some reports in Word with VBScript
> which I call from the main app which is written in C++.
>
> Comming to VBA and VBScript from C++
> there are a lot of conceptual similarities along
> with some rather significant differences - sort of like
> a person who has just mastered German suddenly trying
> to say a few things in Dutch.
>
>
> Thanks Again
> Jim
>
> "Chad DeMeyer" <cjdemeye at bechtel dot com> wrote in message
> news:eMV98MaeEHA.2396@TK2MSFTNGP11.phx.gbl...
> > James, instead of:
> >
> > Do While .Execute
> > oRg.Rows(1).Range.Select
> > Selection.InsertRowsAbove 3
> > Loop
> >
> > you could try:
> >
> > .Execute
> > Do While .Found
> > oRg.Rows(1).Range.InsertRowsAbove 3
> > .Execute
> > .Execute
> > Loop
> >
> > This method executes twice in each loop to go first to the instance you
> > already found, then search for another instance. It uses the .Found
> > property rather than the return value of .Execute to determine if
another
> > instance was found.
> >
> > Regards,
> > Chad
> >
> >
> > "James Pannozzi" <jpannozzi@csi.com> wrote in message
> > news:e5iSULYeEHA.3124@TK2MSFTNGP09.phx.gbl...
> > > Trying to search for the word "Totals"
> > > which occurs towards the end of some tables,
> > > and insert 3 rows above it, then underline two of the
> > > newly inserted rows.
> > >
> > > Can't seem to do it without mixing up the range
> > > and causing an infinite loop.
> > >
> > > Here's the code
> > >
> > > For Each oTbl In objWord.ActiveDocument.Tables
> > > Set oRg = oTbl.Range
> > > With oRg.Find
> > > .ClearFormatting
> > > .Text = "Totals"
> > > .Format = False
> > > .Forward = True
> > > .Wrap = wdFindStop
> > > .MatchWildcards = False
> > > Do While .Execute
> > > oRg.Rows(1).Range.Select
> > > Selection.InsertRowsAbove 3
> > > ' range gets messed up, finds same "Total For" again and
> > again.
> > > Loop
> > > End With
> > > Next
> > >
> > > Thanks
> > > Jim
> > >
> > >
> > >
> >
> >
>
>