Solved

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

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

[b]Ok so now I will show you how to add a user name to the description at login. [/b] First connect to your DC (Domain Controller / Active Directory Server) SET PERMISSIONS FOR SCRIPT TO UPDATE COMPUTER DESCRIPTION TO USERNAME 1. Open Active …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
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 to another domain controller. Log onto the new domain controller with a user account t…

867 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

22 Experts available now in Live!

Get 1:1 Help Now