Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Template - Fill-In Field Question / Hyperlink 1

Status
Not open for further replies.

debbiezzzzz

IS-IT--Management
Aug 24, 2007
58
US
Hello,

I'm currently setting up a template to help users on the network configure signatures to a company format. I currently have the template working with Fill-In Fields that ask the user for their Full Name / e-mail Address / and Job Description. The template then formats a signature for them. This works ok now, but I'd like to have it add two features....

1. I would like it to display the requested e-mail address in hyperlink format. (So it would display abc@xyz.com but the hyperlink would contain mailto:abc@xyz.com) While I can format the display to appear to do this, it's not a hyperlink at this point.

2. Rather then have them type in the Job Description, I would prefer a list to pop up asking them to choose their Job Description from the list. (Then the document would insert it where it currently displays now)

What's nice about Fill-In fields is that they immediately ask the user for this input when they open the template, unlike Ask field type where I think they have to hit F9 or Alt-F9. Any suggestions would be much appreciated.

Thanks,

D
 
1. You can do this with VBA. Here is an example.
Code:
Dim myEmail As String
myEmail = InputBox("email address", "Yadda")
Selection.Hyperlinks.Add Address:="mailto:" & myEmail, _
   Anchor:=Selection.Range, TextToDisplay:=myEmail
This is using an inputbox, but any source of a string is fine.

So I type "fumei@yadda.com" into the inputbox. This becomes the string myEmail. A Hyperlink is added at the Selection - but it could go anywhere.

The Address (or where it goes) is:
mailto:fumei@yadda.com "mailto:" & myEmail

The displayed text (TextToDisplay) is myEmail, or fumei@yadda.com (from the inputbox).

The clicked hyperlink will open the default email application with fumei@yadda.com in the To:


2. You could use a dropdown formfield with short descriptions, which would then insert fuller AutoText that matches the short description. Or an ActiveX dropdown (combobox).

I would be mor einclined to have all this stuff on a userform which opens when a new document is cloned from the template. However, I suspect you are not actually using a real template.

A userform could still be used with a document on open, using the Document_Open event.

The user opens the document, the userform displays, gathers all the information and dumps it into the document.

faq219-2884

Gerry
My paintings and sculpture
 
Thank you very much for the tips. I added the vba code from item 1 into a document / new event. I apologize for my office/vba ignorance, but how do I now have the text placed in a specific part of the document. Currently it appears at the beginning.

I am using .dot files and having the user create a new document from them.

Thanks again,
D
 
I took you're advice and looked at a user form. My only question is how to then build my document from the data in the controls.
 
There are a number of ways. One way is to use bookmarks.

Say, taking the example of the email hyperlink....

1. There is a bookmark in the document named "EmailHere". Note the bookmark is actually in the template (.dot) file, but will of course be in any document cloned from that template.

2. There is a textbox control on the userform named txtEmail.

3. There is a commandbutton on the userform named cmdDone.

When user clicks Done:
Code:
Private Sub Done_Click()
'  other stuff????

ActiveDocument.Hyperlinks.Add Address:="mailto:" & txtEmail.Text, _
   Anchor:=ActiveDocument.Bookmarks("EmailHere").Range, _
   TextToDisplay:=txtEmail.Text

' more other stuff???
Unload Me
End Sub
which puts the hyperlink at the bookmark, displaying the contents of the textbox (txtEmail.Text), but making the Address mailto: & txtEmail.Text


The userform would display when a new document is cloned, using the Document_New event in the template file.

If you have more specific questions you should post to the VBA forum.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top