[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-09-26
8
Medium Priority
?
223 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Clif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
MikeToole earned 2000 total points
ID: 36708504
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
 
LVL 10

Author Comment

by:Clif
ID: 36709199
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
 
LVL 46

Expert Comment

by:aikimark
ID: 36709675
Is this a VSTO application?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Author Comment

by:Clif
ID: 36709751
No.  It's old school (too many versions of MS Office to deal with from 2003 to 2010)
0
 
LVL 46

Expert Comment

by:aikimark
ID: 36709788
>>It's old school

So, is it a VB classic application or a VB.Net application? -- just how 'old' is this school?
0
 
LVL 10

Author Comment

by:Clif
ID: 36710014
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
 
LVL 27

Assisted Solution

by:MikeToole
MikeToole earned 2000 total points
ID: 36710203
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
 
LVL 10

Author Closing Comment

by:Clif
ID: 36710520
That did it.

Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question