Solved

Word Document looping through rows and columns.

Posted on 2014-04-10
2
723 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 51

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
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 video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

729 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