Solved

Word Document looping through rows and columns.

Posted on 2014-04-10
2
570 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
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
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ā€¦
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

777 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