Hi All,
I have created a macro that opens up a Meeting Agenda template document
with a userform. What I've been asked to do is:
1. Ask the user how many attendees are the meeting and insert the same
number of rows in the template document
2. Then when they have entered a number, create the same number of sets
of textbox controls on a userform where they can enter details of
attendees. e.g. Name, Company etc
3. When they have entered these details, the text needs to be inserted
into the relevant cells in the template...The cells that have been
created in 1.
This code has been used for number 1:
Dim rownum As Integer, i As Integer
Dim addrows As Integer, k As Integer
addrows = Val(InputBox( _
Prompt:="Please enter the number of attendeees", _
Title:="Add Table Rows", Default:=""))
If addrows = 0 Then Exit Sub
For k = 1 To addrows
ActiveDocument.Tables(1).Rows.Add
'rownum = ActiveDocument.Tables(1).Rows.Count
For i = 1 To ActiveDocument.Tables(1).Columns.Count
ActiveDocument.Bookmarks.Add Name:="MyBookmark", _
Range:=Selection.Range
Next i
Next k
NoReset = False
I also know how to create a bookmark and insert text into a document,
but I am not sure how to make the code repeat etc creating several
bookmarks and creating sets of controls, according to the number
entered in the dialog box.
Thanks for any help,
Net
Doug Robbins - Word MVP - 06 Oct 2006 20:02 GMT
Seems to me that you are probably trying to use a Sledgehammer to crack a
Walnut. Also, are you really using a userform, which is a custom dialog or
are the controls that you speak of actually FormFields.
I cannot see any real point in using a UserForm for this. It's just as easy
to have a one row table in the template into which the user enters the
details of the first attendee and when they use the tab key in the last cell
on the table, a new row will automatically be added to the table and into
that they would add the details for the next attendee and so on.

Signature
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
> Hi All,
>
[quoted text clipped - 42 lines]
> Thanks for any help,
> Net