Solved

How do can the email be displayed as hyperlink with vbs in this code?

Posted on 2011-02-25
2
361 Views
Last Modified: 2012-05-11
hi guys

I've got this lovely code below, which is for obtaining information from AD and putting it into a word document for signatures.

However, when it pulls the email from AD and into word, it is not displayed as a hyperlink in the word document. So you can't click onto the email address or there's no mailto command, instead the email address is just displayed.

How can we do it so that when the email is pulled from AD, it is displayed as a hyperlink in word?

Here's the code below in case:

'*** Angi filbanen til Wordfilen som fungerer som signaturmal ***
filepath = "C:\Users\yashars\Desktop\signature.docx"


'*** Connecting to AD***

Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

'*** Fetching user info from AD and store these in variables ***

strName = objUser.FullName
 
strTitle = objUser.Title

strTelephoneNumber = objUser.TelephoneNumber

strEmailAddress = objUser.EmailAddress

'*** Other values that may be relevant***

'strMobile = objUser.Mobile
'strEmailAddress = objUser.EmailAddress
'strDepartment = objUser.Department
'strCompany = objUser.Company
'strFax = objUser.Faxnumber
'strLocation = objuser.physicalDeliveryOfficeName
'strAddress = objuser.streetAddress
'strCity = objuser.l
'strState = objuser.st
'strZip = objuser.postalCode
'strWeb = objuser.wWWHomePage
'strInfo = objuser.info


'*** Exiting the link with AD***

Set objUser = Nothing
Set objSysInfo = Nothing


'*** Open the Word file to be used as a template ***

Set objWord = CreateObject("Word.Application")
objWord.Visible = False '*** Set this to True is the Word, while the signature is created.
objWord.Documents.Add (filepath)

'*** Assigns values to the bookmarks in the Word file***

objWord.ActiveDocument.Bookmarks("Name").Select '*** Goes to bookmark
objWord.Selection.Text = strName               '*** Setting the right value at the bookmark
objWord.ActiveDocument.Bookmarks("Name").Delete '*** Removes the bookmark
   
objWord.ActiveDocument.Bookmarks("Title").Select
objWord.Selection.Text = strTitle
objWord.ActiveDocument.Bookmarks("Title").Delete
   
objWord.ActiveDocument.Bookmarks("Telph").Select
objWord.Selection.Text = strTelephoneNumber
objWord.ActiveDocument.Bookmarks("Telph").Delete

objWord.ActiveDocument.Bookmarks("Email").Select
objWord.Selection.Text = strEmailAddress
objWord.ActiveDocument.Bookmarks("Email").Delete



'*** Select the content in Word file ***

Set objSelection = objWord.ActiveDocument.Range()

'*** Overrides fonts, and skrifstørrelse (essential to resolve the probleme with different fonts, a standard type) ***

objSelection.Font.Name = "Franklin Gothic Book"
objSelection.Font.Size = 10

'***  Sets the contents of the Word file as a signature in Outlook ***

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSignatureEntries.Add strname, objSelection
objSignatureObject.NewMessageSignature = strname
objSignatureObject.ReplyMessageSignature = strname

'*** Ends the connection from Outlook ***

Set objSignatureEntries = Nothing
Set objSignatureObject = Nothing
Set objEmailOptions = Nothing
Set objSelection = Nothing

'*** Closes the link to the Word ***

objWord.ActiveDocument.Close (False)
objWord.Quit
Set objWord = Nothing

'*** Dialog box to use with the information that the signature is updated.

msgbox "Your Outlook signature was updated ", vbInformation," Outlook signature"



Many thanks
Yashy
0
Comment
Question by:Yashy
2 Comments
 
LVL 21

Accepted Solution

by:
snusgubben earned 500 total points
ID: 34982632
Why do you want it to be displayed as a mailto link in Word?

When the signature is written to the users Outlook profile and the user sends an email (html formatted), the receiver will see it as a mailto link if he also reads mail html formatted.
0
 
LVL 1

Author Comment

by:Yashy
ID: 34988878
I didn't realise that. I'll check it out, thanks for the update on that snsgubben:)
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question