Equiv. of .TypeText method using a Range obj

M

Mindy

oWord is a Word document object. This code worked fine
using a Selection object. But I have now defined a range
object (oRange), because the oWord document object is so
long that it is taking too much time to run all the code
in this routine using the entire document. So oRange is
just the portion of the document I need.

The majority of the code has been modified to use the
Range object. But this snippet I cannot quite get tweaked
to use the Range object. This code is taking three values
from a data row view and putting it in three columns of a
table. What is the equiv of .TypeText using a Range object?

oWord.Selection.TypeText(Text:=drv.Row.Item
("NextDate").ToString)
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
oWord.Selection.TypeText(Text:=drv.Row.Item
("NextDeadline").ToString)
oWord.Selection.MoveRight(Unit:=Word.WdUnits.wdCell)
oWord.Selection.TypeText(Text:=drv.Row.Item
("Location").ToString)

Appreciate any input. Thanks.
 
J

Jezebel

You can use the .InsertBefore and .InsertAfter methods. Or if you are
working with plain text you can set the range's text property. Since the
..Text property is the default property of a range, you can leave it out and
just set the range directly:

There are any number of ways to get references to the individual cell
ranges, eg

With ActiveDocument.Tables(1)
.cell(1,1).Range = drv.Row.Item("NextDate").ToString
.cell(1,2).Range = drv.Row.Item("NextDeadline").ToString
end with


etc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top