?
Solved

Word Document looping through rows and columns.

Posted on 2014-04-10
2
Medium Priority
?
786 Views
Last Modified: 2014-04-11
Experts, the code below really explains what i want to do. I could use:
For i AS integer = 1 to oTable.columns.count

But I would really prefer to use the for each loop. Is this possible?
Can you show me how to make it work?
Dim oWord AS New Word.Application
Dim oDoc as Word.Document = oWord.Documents.Add
Dim oTable as Word.Table
oWord.range.select
oTable = oDoc.tables.Add(oWord.selection.range, rowCount, columnCount)
For Each orow As Word.Row In oTable.Rows
     For Each oColumn As Word.Column In oTable.Rows(oRow.Index)
          'do column stuff
     Next
Next

Open in new window

0
Comment
Question by:Basicfarmer
[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
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39993503
Hi,

pls try

Dim oWord As New Word.Application
Dim oDoc as Word.Document = oWord.Documents.Add
Dim oTable As Word.Table
oWord.Range.Select
oTable = oDoc.Tables.Add(oWord.Selection.Range, RowCount, columnCount)
For Each oRow As Word.Row In oTable.Rows
     For Each oCell As Word.Cell In oRow.Cells
          'do column stuff
     Next
Next

Open in new window

Regards
0
 

Author Closing Comment

by:Basicfarmer
ID: 39993529
Ok, I get it now. Great answer as usual...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

800 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