Creating userform

R

Robert

Is there an easy way to convert text from a document into
a userform? The document has numerous lines that is
basically a checklist. The user checks off which lines
appear in the final document. There are hundreds of lines,
some are labels and others would go into textboxes.
Copying each line into the userform is tedious to say the
least. Is there some way to automate the transfer instead
of doing it line by line? Thanks.
 
C

Cindy M -WordMVP-

Hi Robert,
Is there an easy way to convert text from a document into
a userform? The document has numerous lines that is
basically a checklist. The user checks off which lines
appear in the final document. There are hundreds of lines,
some are labels and others would go into textboxes.
Copying each line into the userform is tedious to say the
least. Is there some way to automate the transfer instead
of doing it line by line?
You mean, some magic wand you could wave that says, get all
the checked stuff and dump it into my form, and I don't have
to tell you what goes where?

Nope. You have to code it. Whether there's an easier way to
do it than what you're currently considering there's no way
of saying, since we don't know any details.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep
30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
R

Robert

Let me try to be more explicit. (I'm not looking for a
magic wand, but I wouldn't turn it down. I just don't want
to reinvent the wheel.)I know I will have to write the
code, but first I am trying to get the lines from the
document into the userform. I can create textboxes for a
few lines one at a time, but if there are hundreds of
lines, it becomes tedious. For example, say I have a
document with three lines:
Line 1
Line 2
Line 3
Now I want to enter these lines into a userform where each
line will be the caption of a checkbox. I could do this
manually, but could I bookmark each of the lines then
create a module to put them into the userform in the same
position they are in the document? Could I use the range
of the bookmark to create the control in the userform
using:
userform.Designer.Controls.Add("Forms.CheckBox.1")and then
set the properties for the checkbox:
With CheckBox.1
.Name="CheckBox1"
.Caption= activedocument.bookmarks("BM1").Text
.Left=
.Top=
I'm not sure how the range for a bookmark translates into
a location in the userform. If this approach would work, I
could just loop through the all the bookmarks and put them
into the userform. Then I could write the code which would
delete the bookmark if the checkbox is not checked. Am I
on the right track?? Thanks.
 
J

Jay Freedman

Hi, Robert,

You can do something of this sort by code in the Userform_Initialize()
procedure of the userform. For a reasonably gentle introduction, see
the article at
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=259.

You're going to have to work out the algorithm for positioning labels
and controls on the userform for yourself -- this will be highly
dependent on exactly how your document is structured and what you want
the userform to look like.

You will *not* be able to put hundreds of labels and controls on a
single userform. For one thing, one of the MVPs recently mentioned
that there's a limit of 400 objects on a userform (I don't know
whether this is officially documented somewhere). For another thing,
you'll run out of screen real estate long before that, and your user's
eyes will glaze over at somewhere around 40 or 50. You need to
investigate the MultiPage control, which lets you show tabbed "pages"
within the userform, and probably go to multiple userforms.
 
R

Robert

Thanks for your replies. I was really looking for
something I could use at design time rather than at run
time.
 
C

Cindy M -WordMVP-

Hi Robert,
I was really looking for
something I could use at design time rather than at run
time.
Like what's described in this KB article?

OFF97: How to Programmatically Manipulate a UserForm
[Q185774]
http://support.microsoft.com?kbid=185774

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top