Autonumber Field forms

R

rachitm

Is there a way I could Autonumber a column? I have an insert row button
for a table and I was wondering if I could make the first column
autonumber itself (1..2..3..) when I press the insert row button.


# PARENT NAME
1. <field form>
2. <field form>
3. <field form>

.......and so on.....
 
G

Greg Maxey

If you build your table with a SEQ field in column 1 row 2 using
something like { SEQ myCol} then a macro like this may do:

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim myRng As Range
Dim i As Long
If Selection.Information(wdWithInTable) Then
Set oTbl = Selection.Tables(1)
oTbl.Rows.Add
i = oTbl.Rows.Count
Set myRng = oTbl.Cell(i, 1).Range
myRng.Collapse
oTbl.Range.Fields.Add myRng, wdFieldEmpty, Text:="SEQ myCol"
Else
MsgBox "The cursor is not in a table"
End If
End Sub
 
R

rachitm

Thanks Greg for your help! This works :)


Greg said:
If you build your table with a SEQ field in column 1 row 2 using
something like { SEQ myCol} then a macro like this may do:

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim myRng As Range
Dim i As Long
If Selection.Information(wdWithInTable) Then
Set oTbl = Selection.Tables(1)
oTbl.Rows.Add
i = oTbl.Rows.Count
Set myRng = oTbl.Cell(i, 1).Range
myRng.Collapse
oTbl.Range.Fields.Add myRng, wdFieldEmpty, Text:="SEQ myCol"
Else
MsgBox "The cursor is not in a table"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top