[bksvol-discuss] Re: Rewritten macro for finding tables in word

  • From: Melissa Smith <mdsmith25@xxxxxxxx>
  • To: bksvol-discuss@xxxxxxxxxxxxx
  • Date: Mon, 15 Feb 2010 07:24:37 -0600

Judy,
Thanks. I'll use this one next time.

Melissa


Judy s. wrote:
Hi, Melissa,

I should have tested this out myself rather than trusting Microsoft - they have a bug in their code! grin. I asked my husband to take a look at it too, and he came up with a better macro, based on this one, that lets you find a table, and then stop and work on that table if you choose, or go on and search for the next table. I've tested it out myself to search for tables, and it worked perfectly for me, letting me stop if I wanted to and exit the search at the point where the table occurs, with that entire table selected, or go on to find the next table.

Here it is:

Sub FindTables()
      Dim iResponse As Integer
      Dim tTable As Table
      'If any tables exist, loop through each table in collection.
      For Each tTable In ActiveDocument.Tables
         tTable.Select
iResponse = MsgBox("Table found. Click OK for the next table or Cancel to quit?", _
                             vbInformation + vbOKCancel)
         If iResponse <> vbOK Then Exit For 'User chose to leave search.
      Next
      MsgBox prompt:="Search Complete.", buttons:=vbInformation
   End Sub

So, if you ever run into this again, this should work better. smile.

Judy s.


Quoting Melissa Smith <mdsmith25@xxxxxxxx>:

Judy, This did work. The only disadvantage is that you had to cycle
through all the tables before you could get out of it tow work with the
table. I would imagine that this behavior could be modified, but I
don't know enough about visual basic to change it. At any rate, it
worked, and was much faster than any other way I've found so far.

Thanks,

Melissa


Judy s. wrote:
Melissa, I can't find anything in Word per se to let you search for the codes that identify a table.

However, I did find this on Microsoft's website - a macro you can use to find tables - from http://support.microsoft.com/kb/212692

You need to program it in using the visual basic editor. Here's the code:

Sub FindTables()
     Dim iResponse As Integer
     Dim tTable As Table
     'If any tables exist, loop through each table in collection.
     For Each tTable In ActiveDocument.Tables
        tTable.Select
        iResponse = MsgBox("Table found. Find next?", 68)
        If response = vbNo Then Exit For 'User chose to leave search.
     Next
     MsgBox prompt:="Search Complete.", buttons:=vbInformation
  End Sub

Let me know if you try it, and if it works. smile.

Judy s.

Melissa Smith wrote:
I want to find the tables. I thought there would probably be something to search for in Word's find and replace dialog like the ^m for page breaks. This way I could find each one, and then convert it to text, which I know how to do.
Thanks,

Melissa

To unsubscribe from this list send a blank Email to
bksvol-discuss-request@xxxxxxxxxxxxx
put the word 'unsubscribe' by itself in the subject line. To get a list of available commands, put the word 'help' by itself in the subject line.


To unsubscribe from this list send a blank Email to
bksvol-discuss-request@xxxxxxxxxxxxx
put the word 'unsubscribe' by itself in the subject line.  To get a
list of available commands, put the word 'help' by itself in the
subject line.


To unsubscribe from this list send a blank Email to
bksvol-discuss-request@xxxxxxxxxxxxx
put the word 'unsubscribe' by itself in the subject line. To get a list of available commands, put the word 'help' by itself in the subject line.


To unsubscribe from this list send a blank Email to
bksvol-discuss-request@xxxxxxxxxxxxx
put the word 'unsubscribe' by itself in the subject line.  To get a list of 
available commands, put the word 'help' by itself in the subject line.

Other related posts: