L
LizW
Our office often has to number the leftmost column in a
table. If we do it manually, and then insert and delete
rows, we have to renumber everything from scratch. I'd
like to create a macro that will insert the Autolglnum
field (because it updates on insert or delete rows) and
continue to loop until it reaches the end of the table. It
could be 66 rows or 157 rows - so I can't use For, or
Repeat commands if I have to specify a number each time.
So far I have this:
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
"AUTONUMLGL \* Arabic \e ",
PreserveFormatting:=False
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
"AUTONUMLGL \* Arabic \e ",
PreserveFormatting:=False
This puts in the number 1 in the first row, goes down, and
inserts the number 2 in the next row. However I would then
like it to repeat and look until the cursor comes to the
end of the table. I don't know how to Repeat the Actions
that came before and also, I'm not sure how to
specify "the end of the table" in VBA.
Any ideas? Thanks!
table. If we do it manually, and then insert and delete
rows, we have to renumber everything from scratch. I'd
like to create a macro that will insert the Autolglnum
field (because it updates on insert or delete rows) and
continue to loop until it reaches the end of the table. It
could be 66 rows or 157 rows - so I can't use For, or
Repeat commands if I have to specify a number each time.
So far I have this:
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
"AUTONUMLGL \* Arabic \e ",
PreserveFormatting:=False
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Fields.Add Range:=Selection.Range,
Type:=wdFieldEmpty, Text:= _
"AUTONUMLGL \* Arabic \e ",
PreserveFormatting:=False
This puts in the number 1 in the first row, goes down, and
inserts the number 2 in the next row. However I would then
like it to repeat and look until the cursor comes to the
end of the table. I don't know how to Repeat the Actions
that came before and also, I'm not sure how to
specify "the end of the table" in VBA.
Any ideas? Thanks!