WD: WordBasic Macro to Find Tables in a Word DocumentLast reviewed: February 2, 1998Article ID: Q88540 |
The information in this article applies to:
SUMMARYYou can use the EditGoto statement in Word to move to the next table in your document. The "t" identifier is used to specify a table. The following statement moves the insertion point to the first cell in the next table.
EditGoTo "t+" 'moves to the next tableYou can use the EditFind command to search for a number of special characters. However, this command cannot be used to locate a table in a Word for Windows document. To search for tables in a document, use the following macro:
Sub MAINStartOfDocument While CmpBookmarks("\sel", "\endofdoc") 'While loop n = SelInfo(12) 'Returns -1 if in table If n = - 1 Then 'If -1 is returned post message choice = MsgBox("Table found, find next table?", 4) If choice = 0 Then Goto bye If choice = - 1 Then 'If OK pressed, find next. TableSelectTable CharRight 1 EndIf Else LineDown 'If no table found, line down 1 End IfWend bye: End Sub MORE INFORMATIONThe above macro uses a While Wend loop to search through the document for tables. The macro uses the SelInfo command to determine if the cursor is in a Word for Windows table. SelInfo(12) will return a -1 if the selection is in a Word table, and Word displays a message box with the text "Table Found." If the selection does not contain a table, the macro will move the cursor to the next line in the document. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, pages 277-278, 333 Kbcategory: kbusage kbmacro KBSubcategory: kbtable |
Additional query words: winword2 word6 7.0 word95 word7 6.0.1
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |