Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.tables
Tom Tom is offline
external usenet poster
 
Posts: 61
Default identifying a specific table in a macro?

I have two types of tables in my document -- one for reference
information, and one for notes, cautions, etc. The former tables have
borders, but the latter do not.

I currently have a macro that formats all tables with a specific
format.

How would I make it so that the macro only formats one type of tables
in my document? In other words, so that it formats reference tables
with borders, and note tables without borders?

Here's the macro (actually from Peter Grainge's site) that I'm using to
format all tables:

Sub FormatTablesAll()
' Runs through all tables in the document and applies the properties
defined.
' Does not give user option to skip a table.
' This starts the macro at the start of the document
Selection.HomeKey Unit:=wdStory
'This declares the variable that counts the number of tables.
Dim iNumber As Integer
iNumber = ActiveDocument.Tables.Count
' This stops the macro running if there are no tables
If iNumber = 0 Then
MsgBox "There are no tables in this document"
End
Else
'This declares the variable that numbers the current table.
Dim iCurrent As Integer
For iCurrent = 1 To iNumber
' This finds the next table
Selection.GoTo what:=wdGoToTable, which:=wdGoToNext, Count:=1, Name:=""
' This selects the table
With Selection
.SelectColumn
.SelectRow
End With
' This formats the table
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.Color = RGB(0, 0, 0)
End With
' Enter other requirements here
End With
Selection.Collapse
' This loops to the next table until all the tables have been
processed.
Next iCurrent
End If
MsgBox "All tables have been formatted."
End Sub

Thanks for your help.

 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Table Background Macro Jeff Ditty Tables 1 March 28th 06 04:32 AM
Macros:How to select a specific column of a table and format it using macro? evg999 Tables 3 January 31st 06 11:20 AM
Select specific cells in table via macro Bill Sturdevant Microsoft Word Help 1 July 27th 05 03:01 PM
How do I create a macro that is a table in word InlovewithJJ Tables 1 April 29th 05 12:42 AM
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM


All times are GMT +1. The time now is 07:39 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"