Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Creating rows with bookmarks and controls on a userform in code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aef1@lycos.co.uk - 06 Oct 2006 16:24 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.