Page 1 of 1 1
Topic Options
#201776 - 2011-03-24 02:51 PM Scripting for Outlook sig
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
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?

Top
#201777 - 2011-03-24 04:35 PM Re: Scripting for Outlook sig [Re: sparkie]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
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.


Top
#201780 - 2011-03-24 05:11 PM Re: Scripting for Outlook sig [Re: Allen]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
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

Top
#201781 - 2011-03-24 05:34 PM Re: Scripting for Outlook sig [Re: sparkie]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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))


Edited by Mart (2011-03-25 08:50 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#201787 - 2011-03-25 09:09 AM Re: Scripting for Outlook sig [Re: Mart]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
Many thanks Mart, I'll have a read and play then come back with some feedback.
Top
#201788 - 2011-03-25 09:33 AM Re: Scripting for Outlook sig [Re: sparkie]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
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

Top
#201789 - 2011-03-25 09:50 AM Re: Scripting for Outlook sig [Re: sparkie]
sparkie Offline
Getting the hang of it

Registered: 2010-09-14
Posts: 92
Loc: UK
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

Top
#201791 - 2011-03-25 03:27 PM Re: Scripting for Outlook sig [Re: sparkie]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
You can't combine kix scripting language and visual basic scripting into the same file if that's what you're asking.
Top
#201794 - 2011-03-26 11:51 AM Re: Scripting for Outlook sig [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good answer!
it actually seems he wants to make this happen with vbs and wants us to help with it...
_________________________
!

download KiXnet

Top
#201800 - 2011-03-27 12:59 PM Re: Scripting for Outlook sig [Re: ShaneEP]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
 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.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#201801 - 2011-03-27 05:58 PM Re: Scripting for Outlook sig [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
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.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.06 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org