Brian
Mon Oct 22 00:41:04 PDT 2007
Thank you Shauna.
It worked a treat. One more question if its not too cheeky, Would it be
possible to not only identify the table to delete by the number of columns,
but also by the word Action in the second column of the table header row? At
the moment, I copy the relevant section to a new document, tidy the section,
then copy it back.
I am stripping out screen captures and step tables from large documents cica
300 pages to reduce to 30 pages. SOPs.
Thanks,
--
Brian McCaffery
"Shauna Kelly" wrote:
> Hi Brian
>
> Try this....
>
> Sub delTables()
>
> Dim nCounter As Long
> Dim nNumTables As Long
> Dim oTable As Word.Table
>
> 'Find out how many tables there are
> nNumTables = ActiveDocument.Tables.Count
>
> 'Start at the last table, and work backwards
> 'through the tables in the document.
> 'We do this because we are deleting tables,
> 'and the index would go awry as we cycled
> 'through them.
> For nCounter = nNumTables To 1 Step -1
>
> 'Get a reference to this table
> Set oTable = ActiveDocument.Tables(nCounter)
>
> 'If the table has 2 columns...
> If oTable.Columns.Count = 2 Then
> '...delete it
> oTable.Delete
> End If
>
> Next nCounter
>
> End Sub
>
> Hope this helps.
>
> Shauna Kelly. Microsoft MVP.
>
http://www.shaunakelly.com/word
>
>
> "Brian" <Brian@discussions.microsoft.com> wrote in message
> news:693D1B6A-774C-4C12-BC86-975A49FE3632@microsoft.com...
> > Hi all,
> >
> > I am trying to find all tables containing only 2 columns in a document,
> > select them, and then delete. Getting no where fast. Any suggestions
> > gratefully received.
> >
> > Sub delTables()
> > Dim oTbl As Table
> > For Each oTbl In ActiveDocument.Tables
> > With ActiveDocument.Tables
> > If NumColumns = 2 Then
> > 'If ActiveDocument.Tables.Count >= 1 Then
> >
> > ActiveDocument.Tables.Select
> > Selection.Delete
> > End If
> > End With
> > Next oTbl
> >
> > End Sub
> >
> > Thanks,
> > --
> > Brian McCaffery
>
>
>