View Single Post
  #13   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Auto number a column in table using SEQ

Kaz,

You could add a prompt:
{ Macrobutton Scratchmacro "Double click to count items: { Docvariable
myVar }" }

AFAIK other than that, you would have to assign the macro to a keyboard
shortcut, menu, or toolbar icon.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Greg Maxey" wrote in message
...
Alot will depend on how you define an "item." Do you mean a cell
containing any text?

Something like this may do. You can nest a docvarialbe field in a macro
button field to execute:

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim i&
Dim rowCnt&
Dim colCnt&
Dim myVar As Variable
Set oTbl = ActiveDocument.Tables(1)
For rowCnt = 2 To oTbl.Rows.Count
For colCnt = 1 To oTbl.Columns.Count
If Len(oTbl.Cell(rowCnt, colCnt).Range.Text) 2 Then
i = i + 1
End If
Next colCnt
Next rowCnt
ActiveDocument.Variables("myVar").Value = i
ActiveDocument.Fields.Update
End Sub

The field will look something like this:

{ Macrobutton Scratchmacro {DocVariable myVar}}

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Suzanne S. Barnhill wrote:
You might want to have a look at
http://gregmaxey.mvps.org/Table_Cell_Data.htm. If this macro doesn't
do what you need, perhaps Greg could enhance it so that it would. I
would think that any macro that could put information in the status
bar could also write it to a document property or variable that could
be picked up in the doc with a DocProperty or DocVariable field.


"kaz" wrote in message
oups.com...
I have a field, outside of the table, that needs to display the count
of the number of items in the table (excluding the header row).