sparkie
(Getting the hang of it)
2011-03-24 02:51 PM
Scripting for Outlook sig

Not sure this is the right place for this but here goes.

I have script and I need to make three areas of text have different hyperlinks

objSelection.TypeText "this test| this text | this text"

I've seen some code to make a single link of text link, but not three different ones side by side.

Is it possible?


AllenAdministrator
(KiX Supporter)
2011-03-24 04:35 PM
Re: Scripting for Outlook sig

See the following thread:
http://www.kixtart.org/forums/ubbthreads...true#Post185794

It seems like you should be able to put together a couple of these hyperlink.add lines.



sparkie
(Getting the hang of it)
2011-03-24 05:11 PM
Re: Scripting for Outlook sig

Thanks, I did see that but could not make head or tail of it.

Not too sure which parts I need and where it will sit in my script


Mart
(KiX Supporter)
2011-03-24 05:34 PM
Re: Scripting for Outlook sig

Hi Sparkie,

This is actually not so difficult as it might look.
You can write the text in three different sections. Setting different hyperlinks to each of them will be much easier this way.
Have a look at the example below. This will write Homepage: http://www.somepage.com | Webshop: http://www.somewebshop.com . The link is placed on the actual URL and not the text surrounding it by calculating the length of the URL and applying the link and some formatting to it.

Both have different links and some formatting applied to them. Adding a third one is just a matter of copying one section and modifying it to match you text, link and formatting and you're done. The last line writes a Chr(11) which is the same as @CRLF in kix.

I use this in our logon script to create e-mail signatures that match our company guidelines. The font name, size and colors variables are set earlier in my script and the URL's are taken from the user info in AD.

 Code:
$objSelection.TypeText("Homepage: ")
;Insert and select hyperlink and set font and attributes for the selection.
$objLink = $objSelection.Hyperlinks.Add($objSelection.Range, $site,, "homepage", $site)
;Calculate where the hyperlink begins.
;Start selection at total length of all text minus the length of the url and select everything to the end of the text.
$Selectionsite = $objDoc.Range($objSelection.End - (Len($site) + 1), $objSelection.End)
;Set font, size and underline for selection.
$Selectionsite.Font.Name = $fontname
$Selectionsite.Font.Size = $fontmedium
$Selectionsite.Font.Underline = 0
$Selectionsite.Font.Color = $fontgray
		
$objSelection.Font.Color = $fontblue
$objSelection.TypeText(" | ")
$objSelection.Font.Color = $fontgray
		
$objSelection.TypeText("Webshop: ")
;Insert and select hyperlink and set font and attributes for the selection.
$objLink = $objSelection.Hyperlinks.Add($objSelection.Range, $shop,, "webshop", $shop)
;Calculate where the hyperlink begins.
;Start selection at total length of all text minus the length of the url and select everything to the end of the text.
$Selectionshop = $objDoc.Range($objSelection.End - (Len($shop) + 1), $objSelection.End)
;Set font, size and underline for selection.
$Selectionshop.Font.Name = $fontname
$Selectionshop.Font.Size = $fontmedium
$Selectionshop.Font.Underline = 0
$Selectionshop.Font.Color = $fontgray
$objSelection.TypeText(Chr(11))


sparkie
(Getting the hang of it)
2011-03-25 09:09 AM
Re: Scripting for Outlook sig

Many thanks Mart, I'll have a read and play then come back with some feedback.

sparkie
(Getting the hang of it)
2011-03-25 09:33 AM
Re: Scripting for Outlook sig

Mart, excuse me for being so daft (I'm not a scripter by trade) but could I copy the above code into a new .vbs and simply run it to see what it will do in Outlook, since I already have a vbs file that I'm toying with?

Mark


sparkie
(Getting the hang of it)
2011-03-25 09:50 AM
Re: Scripting for Outlook sig

I thought I'd show my current code

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
sPicFile = "\\ARTIC\Office2007ProPlus\Scripts\Logo.PNG"
sLinkFile = "http:\\www.website.org"

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
if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
objSelection.TypeParagraph()
objSelection.TypeText strTitle
objSelection.TypeText "My Company name"
objSelection.TypeText Chr(11)
objSelection.TypeText strStreet
objSelection.TypeText Chr(11)
objSelection.TypeText "PHONE: " & strPhone
objSelection.TypeText Chr(11)
if (strFax) Then objSelection.TypeText "FAX: " & strFax & Chr(11)
if (strMobile) Then objSelection.TypeText "CELL: " & strMobile & Chr(11)
objSelection.TypeText "EMAIL: " & strEmail
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
Set objShape1 = objSelection.InlineShapes.AddPicture(sPicFile, True)
objDoc.Hyperlinks.Add objShape1.Range, sLinkFile
objSelection.TypeText Chr(11)
objSelection.TypeText "this is a link | this is a link | this is a link"
objSelection.TypeText Chr(11)
objSelection.TypeText "________________________________"
objSelection.TypeText Chr(11)
objSelection.TypeText "CONFIDENTIALITY NOTICE"

Set objSelection = objDoc.Range()

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

objDoc.Saved = True
objWord.Quit

I have several issues with it but I'd like to get the links sorted first


ShaneEP
(MM club member)
2011-03-25 03:27 PM
Re: Scripting for Outlook sig

You can't combine kix scripting language and visual basic scripting into the same file if that's what you're asking.

LonkeroAdministrator
(KiX Master Guru)
2011-03-26 11:51 AM
Re: Scripting for Outlook sig

good answer!
it actually seems he wants to make this happen with vbs and wants us to help with it...


Mart
(KiX Supporter)
2011-03-27 12:59 PM
Re: Scripting for Outlook sig

 Originally Posted By: CitrixMan
You can't combine kix scripting language and visual basic scripting into the same file if that's what you're asking.


Why do people keep thinking this is a board about VBS? Later I might go over to some home decoration board and ask them how to fix my car. LOL

Originally I translated it from VBS to kix and added some stuff for the links. See: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=179911 and: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=2&Number=180549. I guess it can be translated back to VBS but I'm almost blind in the VBS world so I can't give you a push into the right direction without the risk of pushing you off a cliff.


Arend_
(MM club member)
2011-03-27 05:58 PM
Re: Scripting for Outlook sig

I could translate it to VBS easily, but I won't. This is a KiX forum, not a VBS forum. Mart has been kind enough to do most of the work for you. But you have to put in some effort into learning this and use the better language instead.