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

Tip: Looking for answers? Try searching our database.

Check Box to add text to form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
robandcurtis@gmail.com - 16 Mar 2006 16:06 GMT
I have, with the help of instructions at word.mvps.org, created my
first UserForm. The form gathers info, inserts it into a boilerplate
template, copies the completed text to the clipboard and closes the
form. We can then paste the completed form into an email. I have
created five templates with the five "signatures" of the people who
fill in these forms, but would like the ability to put a check box or
drop down that would allow me to have one form so that each person
could "pick" the signature they wanted to use. Any help appreciated.
Here is the code so far:

Private Sub CommandButton1_Click()
With ActiveDocument
   .Bookmarks("FirstName").Range _
   .InsertBefore TextBox1
   .Bookmarks("LastName").Range _
   .InsertBefore TextBox2
   .Bookmarks("LoginID").Range _
   .InsertBefore TextBox3
   .Bookmarks("GWLogin").Range _
   .InsertBefore TextBox3
   .Bookmarks("Password").Range _
   .InsertBefore TextBox4
   .Bookmarks("GWPass").Range _
   .InsertBefore TextBox4
   .Bookmarks("Context").Range _
   .InsertBefore TextBox5
   .Bookmarks("CLID_ID").Range _
   .InsertBefore TextBox3
   .Bookmarks("CLID_CONT").Range _
   .InsertBefore TextBox5
   .Bookmarks("Department").Range _
   .InsertBefore TextBox6
   .Bookmarks("PO").Range _
   .InsertBefore TextBox7
   .Bookmarks("GW_GROUPS").Range _
   .InsertBefore TextBox8
   .Bookmarks("SMTP_FN").Range _
   .InsertBefore TextBox1
   .Bookmarks("SMTP_LN").Range _
   .InsertBefore TextBox2
   .Bookmarks("GWWA").Range _
   .InsertBefore TextBox3
   .Bookmarks("GWAA_PASS").Range _
   .InsertBefore TextBox4
   .Bookmarks("DESKTOP_ID").Range _
   .InsertBefore TextBox3
   .Bookmarks("ADD_DIR").Range _
   .InsertBefore TextBox10
   .Bookmarks("LINX_ID").Range _
   .InsertBefore TextBox3
   .Bookmarks("LINX_PASS").Range _
   .InsertBefore TextBox4
   .Bookmarks("LINX_Position").Range _
   .InsertBefore TextBox11
   .Bookmarks("EMP_ID").Range _
   .InsertBefore TextBox12
   .Bookmarks("DOB").Range _
   .InsertBefore TextBox13
    Selection.WholeStory
    Selection.Copy
    Application.Quit SaveChanges:=wdDoNotSaveChanges

End With

UserForm1.Hide

End Sub

Private Sub Frame1_Click()

End Sub

Private Sub CommandButton2_Click()
Application.Quit SaveChanges:=wdDoNotSaveChanges

End Sub
Jean-Guy Marcil - 16 Mar 2006 16:53 GMT
robandcurtis@gmail.com was telling us:
robandcurtis@gmail.com nous racontait que :

> I have, with the help of instructions at word.mvps.org, created my
> first UserForm. The form gathers info, inserts it into a boilerplate
[quoted text clipped - 4 lines]
> drop down that would allow me to have one form so that each person
> could "pick" the signature they wanted to use. Any help appreciated.

What format are your signatures (Plain text, images, a mix...)?

By the way, you can delete

Private Sub Frame1_Click()

End Sub

as it does not do anything.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

robandcurtis@gmail.com - 16 Mar 2006 17:37 GMT
Just plain text...
Jean-Guy Marcil - 16 Mar 2006 20:48 GMT
robandcurtis@gmail.com was telling us:
robandcurtis@gmail.com nous racontait que :

> Just plain text...

Then the easiest would be to add a ComboBox and the following code to the
userform:
'_______________________________________
Private Sub UserForm_Initialize()

With Me.ComboBox1
   .AddItem "Select a signature"
   .AddItem "Signature 1"
   .AddItem "Signature 2"
   .AddItem "Signature 3"
   .AddItem "Signature 4"
   .AddItem "Signature 5"
   .ListIndex = 0
End With

End Sub
'_______________________________________

If you already have an Initialize sub, just add the "With-End With" block.

Then, in your CommandButton1_Click sub, add this at the *top*. I have
included basic error trapping so that the user must choose a signature:
'_______________________________________
With Me.ComboBox1
   If .ListIndex = 0 Then
       MsgBox "You must select a signature."
       .SetFocus
       .SelStart = 0
       .SelLength = Len(.Text)
       Exit Sub
   Else
       ActiveDocument.Bookmarks("SigPlace").Range _
           .InsertAfter .Text
   End If
End With
'_______________________________________

Obviously, change the bookmark name ("SigPlace") to suit you needs.

Good luck!
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

robandcurtis@gmail.com - 17 Mar 2006 14:49 GMT
Thank's for your help, Jean Guy. It worked just as you said it would.
 
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.