Solved

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

Posted on 2011-02-25
2
365 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

623 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