Solved

Word Document looping through rows and columns.

Posted on 2014-04-10
2
641 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 50

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 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