Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

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

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
Yashy
Asked:
Yashy
1 Solution
 
snusgubbenCommented:
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
 
YashyAuthor Commented:
I didn't realise that. I'll check it out, thanks for the update on that snsgubben:)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now