[RESOLVED] Stepping through each line in Word2007 VBA
I know Excel VBA quite well, and VB in general, but I'm working in Word and I'm not terribly famlliar with the Word Object model.
I can work within Word Tables quite well, provided the cursor is in one of the cells.
But what I'd like to be able to do is step through each line of a word document to get a table count. Or if there's a way to jump from table to table that would be just as good.
Can anyone point me to a quick code snippet that would get me started? I can build onto it after that.
Thanks.
Jeff
Re: Stepping through each line in Word2007 VBA
Code:
cnt = thisdocument.tables.count
change document object to suit
Code:
for each t in thisdocument.tables
msgbox t.cell(1, 1).range.text
'whatever
next
[SOLVED][WORD]Re: Stepping through each line in Word2007 VBA
Quote:
Originally Posted by
westconn1
Code:
cnt = thisdocument.tables.count
change document object to suit
Code:
for each t in thisdocument.tables
msgbox t.cell(1, 1).range.text
'whatever
next
Ah, many thanks westconn1. That will be a great start for me. - Jeff
Re: Stepping through each line in Word2007 VBA
Quote:
Originally Posted by
westconn1
Code:
cnt = thisdocument.tables.count
change document object to suit
Code:
for each t in thisdocument.tables
msgbox t.cell(1, 1).range.text
'whatever
next
Just thought I would say that I didn't get this to work as posted (probably my fault). But when I used ActiveDocument instead of thisdocument, it did.
thanks.
Jeff
Re: [RESOLVED] Stepping through each line in Word2007 VBA
note the line
change document object to suit
Re: [RESOLVED] Stepping through each line in Word2007 VBA
Quote:
Originally Posted by
westconn1
note the line
change document object to suit
Yup, my bad. Thanks.