Automating Word: Assigning a Range of Cells to a Range Object

I should know this.  I even feel like I've asked before, but can't find it my previous questions.

I have a Word table I created through VB.Net.  The table is 10 columns by 20 rows.  I need to modify the first six columns of the first three rows.

To that end, I'm hoping to do something like this:
(Note: Even though it looks like Excel, it's a Word table)
Dim oRange As Object = oTable.Cells("A1", "F3")

Obvoiusly that doesn't work or I wouldn't be posting here.

How do I do this?

TIA

LVL 10
ClifAsked:
Who is Participating?
 
MikeTooleConnect With a Mentor Commented:
Long time since I worked with the Word object model, but this seems to do the trick (In the ThisDocument code module):

Public Sub TryIt()
Dim t As Table
Set t = Me.Tables(1)
Dim r As Range
Set r = Me.Range(Start:=t.Cell(2, 3).Range.Start, End:=t.Cell(4, 5).Range.End)
r.Select
End Sub
0
 
ClifAuthor Commented:
I'm having problems with the "Me" part of your example.  It doesn't make sense to me, and I have no idea how to convert it to something that does.

Perhaps I wasn't clear enough in my OP.  I'm using VB.Net 2010 Professional.  I'm not doing this within Word's Macro code.
0
 
aikimarkCommented:
Is this a VSTO application?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ClifAuthor Commented:
No.  It's old school (too many versions of MS Office to deal with from 2003 to 2010)
0
 
aikimarkCommented:
>>It's old school

So, is it a VB classic application or a VB.Net application? -- just how 'old' is this school?
0
 
ClifAuthor Commented:
It is a VB.Net (2010 Professional) application creating a Word document for machines with Word 2003, 2007, or 2010 installed.  Because of variety of versions or Word I am to support, my app is using late binding.
0
 
MikeTooleConnect With a Mentor Commented:
The 'Me' prefix refers to the Document instance when used in the ThisDocument class in either vba or vsto.
Replace it with a reference to your document instance.
0
 
ClifAuthor Commented:
That did it.

Thanks
0
All Courses

From novice to tech pro — start learning today.