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 / November 2006

Tip: Looking for answers? Try searching our database.

Inserting Dropdowns or Check boxes in Userform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 02 Nov 2006 00:19 GMT
I have the following code in a userform embedded into a template, which
prompts for input of certain variables in a word document:

Private Sub CommandButton1_Click()

With ActiveDocument
   .Bookmarks("Report_Number").Range _
   .InsertBefore TextBox1
   .Bookmarks("Date").Range _
   .InsertBefore TextBox2
   .Bookmarks("Location").Range _
   .InsertBefore TextBox3
   .Bookmarks("Spool_Details").Range _
   .InsertBefore TextBox4
   .Bookmarks("Pump_Pressure").Range _
   .InsertBefore TextBox5
   .Bookmarks("Name1").Range _
   .InsertBefore TextBox6
   .Bookmarks("Name2").Range _
   .InsertBefore TextBox7
   .Bookmarks("Name3").Range _
   .InsertBefore TextBox8
End With

UserForm1.Hide
End Sub

What I would like to do is change the insertion of the following to either a
dropdown box with 2 or 3 different names or checkboxes with the same 2 or 3
names.

  .Bookmarks("Name1").Range _
   .InsertBefore TextBox6
   .Bookmarks("Name2").Range _
   .InsertBefore TextBox7
   .Bookmarks("Name3").Range _
   .InsertBefore TextBox8

How do I go about this?

Also, when I record a macro, how do I get the cursor to allow me to point
and select text? All it does now is change to an arrow with a cassette button
that does not allow me to do anything that I can tell.

Thanks in advance.
Doug Robbins - Word MVP - 02 Nov 2006 07:54 GMT
Simply replace the TextBox# with the name of the Combobox

You should give the controls meaningful names and you should also use the
.Text property even though it is the default property.

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

>I have the following code in a userform embedded into a template, which
> prompts for input of certain variables in a word document:
[quoted text clipped - 44 lines]
>
> Thanks in advance.
Mark - 02 Nov 2006 12:03 GMT
OK, call me stupid, but I cannot for the life of me get a combobox to work,
and I cannot find anything in the help files that actually helps. Can you
point me in the right direction to find how to add a combobox into the script
I am working on?

Cheers, Mark

> Simply replace the TextBox# with the name of the Combobox
>
[quoted text clipped - 49 lines]
> >
> > Thanks in advance.
Doug Robbins - Word MVP - 02 Nov 2006 13:14 GMT
Are you trying to get code to insert a combobox in a document or to insert
the item that is selected in a combobox on a userform into a bookmark in the
document?

For the latter, you first need to add the combobox to the userform and then
you need to populate it with the information to be selected.  That is
usually done with the Initialize() event of the userform, and for just three
names, it would be simple enough to use the .AddItem function for a combobox

With Combobox1
   .AddItem "Name1"
   .AddItem "Name2"
   .AddItem "Name3"
End With

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

> OK, call me stupid, but I cannot for the life of me get a combobox to
> work,
[quoted text clipped - 61 lines]
>> >
>> > Thanks in advance.
Mark - 02 Nov 2006 18:09 GMT
That did the trick Doug, many thanks!

> Are you trying to get code to insert a combobox in a document or to insert
> the item that is selected in a combobox on a userform into a bookmark in the
[quoted text clipped - 10 lines]
>     .AddItem "Name3"
> End With

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.