Search through all rows in a named table

H

Hcoms

Hello,

How is it possible to search through all rows of a named table using vb?

All the best
 
H

Helmut Weber

Hi,
are you talking about a word-table and about VBA or VB?
This is a Word.VBA group.
A word-table doesn't have a name property, as far as I see.
If I google for "named table", I get posts from sqlserver, access,
Excel and so on, but hardly from word.vba.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 
H

Hcoms

I thought you could name a table in word? Maybe i was wrong! In which case
how can you search through a word table using vba?
 
P

Peter Hewett

Hi Hcoms

You can't name a table in Word you have to either use the table that's currently select or
the tables index number in the document. You can iterate the table using the Rows or
Columns collection but this only works if there are no merged rows/columns. You could use
the tables Cells property and the Cells collection or maybe you could just use the Find
object to search for what you want? You don't say what is you specifically want to do.

HTH + Cheers - Peter
 
H

Hcoms

You are correct , i referenced the table by its number and then used the
cell propertie to get the value of each row
 
H

Helmut Weber

Hi Hcoms,
even with horizontally or vertically merged cells,
this should do:
Sub test445()
Dim t As Table
Dim c As Cell
Set t = ActiveDocument.Tables(1)
For Each c In t.Range.Cells
c.Select
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top