Table refresh / referencing from VBA

C

CJ Brown

Just wondering how to get the reference to the table the insertion point is
in from VBA when a macro is called. I've got around table refresh by forcing
a refresh of all cells in the current doc:

Sub RefreshAllTables()
Dim tbTemp As Table
Dim cellTemp As Cell
For Each tbTemp In ActiveDocument.Tables
For Each cellTemp In tbTemp.Range.Cells
cellTemp.Range.Fields.Update
Next
Next
End Sub

This was fine for a while, but its getting a bit slow now the doc has grown
(and its a nasty fix, whereas I'd like an elegant one). If I could get a
refernce for the table that the insertion point was in, I could have a macro
just to recalc that table. Now I think of it, it might be better just to
force a refresh of only the calculation cells in all the tables ... I'm a bit
new to Word VBA. I'm using Word XP/2002.
 
C

Cindy M.

Hi =?Utf-8?B?Q0ogQnJvd24=?=,
Just wondering how to get the reference to the table the insertion point is
in from VBA when a macro is called. I've got around table refresh by forcing
a refresh of all cells in the current doc:
Set tbTemp = Selection.Tables(1)
Sub RefreshAllTables()
Dim tbTemp As Table
Dim cellTemp As Cell
For Each tbTemp In ActiveDocument.Tables
For Each cellTemp In tbTemp.Range.Cells
cellTemp.Range.Fields.Update
Next
Next
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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