Solved

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

Posted on 2011-02-25
2
358 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

Join & Write a Comment

Suggested Solutions

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Synchronize a new Active Directory domain with an existing Office 365 tenant
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 transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now