?
Solved

How to create hyperlink inside this signature file creation script?

Posted on 2011-04-26
9
Medium Priority
?
670 Views
Last Modified: 2013-11-05
Hey All,

I have a signature file that I would like to add hyperlinks to...Basically the script creates txt, rtf, and html signature files and sets them as the default.  i am just having trouble coding in the hyperlinks.

The first are the two web addresses and the last one is the email address.  Any thoughts the best way to do this?
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

Set WshShell = CreateObject("WScript.Shell")

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

strName = objUser.FullName
strTitle = objUser.Description
strCred = objUser.info
strStreet = objUser.StreetAddress
strLocation = objUser.l
strPostCode = objUser.PostalCode
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Name = "calibri"
objSelection.Font.Size = 10
objSelection.TypeText "If you have any other questions about this, or need any further assistance, please do not hesitate to email or call."
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.TypeText "Thank you,"
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
if (strCred) Then objSelection.TypeText strName & ", "
objSelection.TypeText Chr(11)
objSelection.TypeText strTitle
objSelection.TypeText Chr(11)
objSelection.TypeText "MCITP Enterprise Admin |MCTS|MCSA – Sec |MCSE – Sec |MCP|CompTIA A+, Net+ & Sec+ Certified"
objSelection.TypeText Chr(11)
objSelection.TypeText "COMPANY NAME GOES HERE"
objSelection.TypeText Chr(11)
objSelection.TypeText "ADDRESS GOES HERE"
objSelection.TypeText Chr(11)
objSelection.TypeText "555.555.5555 "
objSelection.TypeText "x" & strPhone
objSelection.TypeText Chr(11)
objSelection.TypeText "http://www.google.com  http://www.facebook.com"
Set objSelection = objDoc.Range()

objSignatureEntries.Add "Full Signature", objSelection
objSignatureObject.NewMessageSignature = "Full Signature"

objDoc.Saved = True
objWord.Quit

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Name = "Arial"
objSelection.Font.Size = 10
objSelection.TypeText "If you have any other questions about this, or need any further assistance, please do not hesitate to email or call."
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.TypeText "Thank you,"
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
if (strCred) Then objSelection.TypeText strName & ", "
objSelection.TypeText Chr(11)
objSelection.TypeText strTitle
objSelection.TypeText Chr(11)
objSelection.TypeText "COMPANY NAME"
objSelection.TypeText Chr(11)
objSelection.TypeText "555.555.5555 "
objSelection.TypeText "x" & strPhone


Set objSelection = objDoc.Range()

objSignatureEntries.Add "Reply Signature", objSelection

objSignatureObject.ReplyMessageSignature = "Reply Signature"

objDoc.Saved = True
objWord.Quit

Open in new window

0
Comment
Question by:blhess
  • 3
  • 3
  • 3
9 Comments
 
LVL 11

Expert Comment

by:TheGorby
ID: 35469985
I have the same script and I tried for a long time to get it to do the exact same thing... with no luck.

However I can advise you that if you remove or comment-out lines 59 and 61 the script runs faster, otherwise the script is unnecessarily quitting Word and recreating another Word object.
0
 

Author Comment

by:blhess
ID: 35470105
Thanks for the cleanup tip.  Yes hopefully you and i both can get some help adding in a link.
0
 
LVL 12

Accepted Solution

by:
rlandquist earned 1000 total points
ID: 35470365
Here you go.  Delete the code on line 52 and then past this code on that line.
So the current line 53 will be moved down several lines

The Chr(9) = TAB, I added 2 because with the text I used they were only 1 space apart.

Let me know how this works for you!
objSelection.TypeParagraph()
Set objRange = objSelection.Range
Set objLink = objDoc.Hyperlinks.Add(objRange, " http://www.google.com ",,, "Google")
objSelection.TypeText Chr(9) & Chr(9)
Set objRange = objSelection.Range
Set objLink = objDoc.Hyperlinks.Add(objRange, " http://www.facebook.com ",,, "Facebook")

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:blhess
ID: 35470430
Thanks!  Worked like a charm!
0
 
LVL 12

Expert Comment

by:rlandquist
ID: 35470471
If my solution worked, why are you requesting this question to be closed accepting your comment?

If my solution worked, you should accept my comment as the solution.

Please let me know your response.

Thanks,
0
 
LVL 11

Expert Comment

by:TheGorby
ID: 35470475
I obviously didn't try hard enough!

I'm objecting to your chosen solution, blhess, only because I assume you accidentally accepted the wrong comment (instead of rlandquist's) as the answer... otherwise that would be awfully mean of you :)
0
 
LVL 11

Expert Comment

by:TheGorby
ID: 35470549
Thanks rlandquist this is great!

Do you know how I would change the font of the hyperlink to Arial? Assuming that's possible?
0
 

Author Closing Comment

by:blhess
ID: 35470562
AWESOME!  Thanks  Worked like a charm
0
 
LVL 12

Expert Comment

by:rlandquist
ID: 35470572
Thanks for fixing the accepted comment, and the grade! ;-)
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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

I am posting this in case anyone runs into similar issues that I did, this may save you a lot of grief: Condition: 1. Your NetBIOS domain name contains an ampersand " & " character.  (e.g. AT&T) 2. You've tried to run any Microsoft installation…
In this article, I will demonstrate that how to do a PST migration from Exchange Server to Office 365. This method allows importing one single PST, or multiple PST's at once.
This video discusses moving either the default database or any database to a new volume.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

621 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