L
LaVerne Defazio
I have a Word Range. It is a section of the document that
contains a table and about a page of text total. I am
doing various text find/replacements in this range object
with no problems. The trouble I have is with a table that
lives in my range. The table has three columns. In the
first column, I have a text string. In the 2nd and 3rd
columns I have no text.
Using this oRange object, I want to "select" the text
string and replace it with a different string
(find/replace). Then I want to tab to the next cell,
insert text, tab to the next cell and insert text. So the
original text string is gone, it has been replaced with
the new string and the entire row of the table has been
populated. Other rows of the same table have the same
setup, so I will be running this same process a couple
times.
In the original code, I used a Selection object for this.
It worked like a champ, but as the document grew to 50 or
100 pages or more it just crawled. So now we're on the
Selection object. I dont need to do a "find" on the entire
document, just within the range. But I cannot get this
table code switched over to the Range. The old code was:
'find the text:
oWord.Selection.Find.Text = str_Original
'replace the text and move out of this cell
oWord.Selection.TypeText(Text:=str_One)
'note: str_Original is gone at this point altho you
'did not use the "replacment" method
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
'in the next cell, type some text, move to next cell
oWord.Selection.TypeText(Text:=str_Two))
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
'in the third cell, type some more text
oWord.Selection.TypeText(Text:=str_Three))
This "type text" stuff worked great, but I cannot seem to
get it switched over to use the Range object.
I am having a heck of a time getting this logic to run
correctly and have been posting many related questions. If
someone could give me some help on this particular
problem, that would be much appreciated. Thanks.
Signed,
LaVerne
contains a table and about a page of text total. I am
doing various text find/replacements in this range object
with no problems. The trouble I have is with a table that
lives in my range. The table has three columns. In the
first column, I have a text string. In the 2nd and 3rd
columns I have no text.
Using this oRange object, I want to "select" the text
string and replace it with a different string
(find/replace). Then I want to tab to the next cell,
insert text, tab to the next cell and insert text. So the
original text string is gone, it has been replaced with
the new string and the entire row of the table has been
populated. Other rows of the same table have the same
setup, so I will be running this same process a couple
times.
In the original code, I used a Selection object for this.
It worked like a champ, but as the document grew to 50 or
100 pages or more it just crawled. So now we're on the
Selection object. I dont need to do a "find" on the entire
document, just within the range. But I cannot get this
table code switched over to the Range. The old code was:
'find the text:
oWord.Selection.Find.Text = str_Original
'replace the text and move out of this cell
oWord.Selection.TypeText(Text:=str_One)
'note: str_Original is gone at this point altho you
'did not use the "replacment" method
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
'in the next cell, type some text, move to next cell
oWord.Selection.TypeText(Text:=str_Two))
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
'in the third cell, type some more text
oWord.Selection.TypeText(Text:=str_Three))
This "type text" stuff worked great, but I cannot seem to
get it switched over to use the Range object.
I am having a heck of a time getting this logic to run
correctly and have been posting many related questions. If
someone could give me some help on this particular
problem, that would be much appreciated. Thanks.
Signed,
LaVerne