![]() |
|
|
|
#1
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Table
Dim oRng As Range
Dim strList As String
Dim oRow As Row
Dim lngRow As Long
For Each oTbl In ActiveDocument.Tables
If oTbl.Style = "Protix Table" Then
Set oRng = oTbl.Range
oRng.Collapse wdCollapseStart
oRng.Move wdParagraph, -1
If Not oRng.Paragraphs(1).OutlineLevel < 10 Then
Do
oRng.Move wdParagraph, -1
Loop Until oRng.Paragraphs(1).OutlineLevel < 10
End If
End If
strList = oRng.Paragraphs(1).Range.ListFormat.ListString
lngRow = 0
For Each oRow In oTbl.Rows
If oRow.Index > 1 Then
lngRow = lngRow + 1
oRow.Cells(1).Range.Text = strList & "." & lngRow
End If
Next oRow
Next oTbl
lbl_Exit:
Exit Sub
End Sub
|
|
#2
|
|||
|
|||
|
It works up until I have other tables in the document aswell
If there is another table style used before the 'protix table' then it doesn't work If there is another table style used after a 'protix table' then it also gives that table an ID number. |
|
| Tags |
| insert number |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Design Macro or Code to Delete Table Rows When Null/Blank/Empty Upon Doc Close/Save
|
aaghd72 | Word VBA | 8 | 02-18-2019 11:22 AM |
| How to find number of coma and then add that number of rows in word using macro? | PRA007 | Word VBA | 7 | 05-27-2015 10:45 PM |
| Creating a table for a variable number of rows | OllieOnline | Mail Merge | 1 | 03-27-2013 02:48 PM |
| Using macro to add variable number of rows to a protected word table | Julia | Word Tables | 1 | 01-09-2013 06:04 AM |
Fixing number or rows in a table
|
burnsie | Word | 2 | 07-12-2011 02:59 AM |