[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-09-26
8
Medium Priority
?
225 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

868 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