View Single Post
  #8   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Newbie Question on on tables

Seems like you do not have the table in the document or the selection
(Cursor) in the table. The macro also assumes that the table already
contains the required number of rows.

The macro can be modified to add the necessary rows, but it would be best to
start with at least one row in the table, which would probably be a header
row anyway. That row should contain the required number of columns and
probably the columns widths adjusted to the requirements.

The following modified macro will add the necessary rows to the table
inserting the required number in the first cell of each row. Once again,
the cursor must be in the table when the macro is run.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

wrote in message
...
On Tue, 05 Dec 2006 09:50:48 +0000, wrote:

On Tue, 5 Dec 2006 05:45:35 +0100, "Doug Robbins - Word MVP"
wrote:

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?"
http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm

Thanks, I'll have a look.

B.N.


Following the advice given in the URL above I arrive with the
following:-



Sub Macro1()
'
' Macro1 Macro
' Macro created 05/12/2006 by Bill Nelson
'

End Sub

Again following the advice as above , I deleted the two lines between
"Sub Macro1() " & "End Sub" into which I then pasted your code given
in your post after removing all the "" symbols which preceeded each
line.

I thus arrived at the following :-



Sub Macro1()


Dim i As Long, j As Long, k As Long
Dim atable As Table
Set atable = Selection.Tables(1)
k = 1
For i = 1 To 123 Step 3
For j = 1 To 3
atable.Cell(i + j - 1, 1).Range.InsertBefore k & Chr(64 + j)
Next j
k = k + 1
Next i
k = 42
For i = 124 To 201 Step 6
For j = 1 To 6
atable.Cell(i + j - 1, 1).Range.InsertBefore k & Chr(64 + j)
Next j
k = k + 1
Next i


End Sub

When I now attempt to run this -( by clicking F5 - is this correct ? )
- I get the error :-
"Run-time error '5941' the requested member of the collection does not
exist "

If I now click "DEBUG" I get the line "Set atable = Selection Tables
(1) " highlighted in yellow.

I'm afraid I don't understand any of this !

B.N.