![]() |
|
|
|
#1
|
|||
|
|||
|
Can With ActiveDocument.Tables() be used only once in a document?
I have several tables in a document that I have different code to perform when the user is in each table. I use With ActiveDocument.Tables(4) with code following then With ActiveDocument.Tables(6) with different code and then With ActiveDocument.Tables(7) with more code. If not what would I use to perform the code as the user moves through the document? Thank you. |
|
#2
|
|||
|
|||
|
It can be used repeatedly as long as you close each instance of
With ActiveDocument.Tables(#) ... with an End With statement Or you might want to run the same code on some multiple tables: Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
For lngIndex = 1 To ActiveDocument.Tables.Count
Select Case lngIndex
Case 1 To 4
With ActiveDocument.Tables(lngIndex)
.Cell(1, 1).Range.Text = "A"
End With
Case 5, 6
With ActiveDocument.Tables(lngIndex)
.Cell(1, 1).Range.Text = "B"
End With
Case 7
With ActiveDocument.Tables(lngIndex)
.Cell(1, 1).Range.Text = "C"
End With
End Select
Next
End Sub
|
|
| Tags |
| tables, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Hopefully you can help RE List of Tables
|
W7PSK | Word | 6 | 06-17-2011 06:55 AM |
Moving Tables
|
b0x4it | Word VBA | 9 | 05-20-2011 01:00 AM |
Pictures in Tables
|
uhlersa | Word Tables | 2 | 03-21-2011 03:21 PM |
| Tables and VBA | spl3001 | Word VBA | 0 | 03-25-2010 02:18 PM |
Array into ComboBox + Macro-Text into ActiveDocument
|
Vivi | Word VBA | 1 | 01-27-2010 07:03 AM |