Home All Groups Group Topic Archive Search About

VBScript Signature in Outlook from TechNet Magazine?

Author
25 Sep 2006 8:11 AM
benb

Hi,

In this months TechNet magazine, there is a couple of pages on scripting
signatures in outlook. One of the sample scripts is a vbscript that queries
active directory, pulls out the user info and then inserts it as a signature.
However the article doesn't say how to set this script up in outlook. I've
tried just adding the script to a signature, but when you insert the
signature it just displays the script as text. How do I assign the script to
the signature so that it will work correctly?

Many thanks

Ben

P.S. Script is below

On Error Resume Next

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

strName = objUser.FullName
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.TelephoneNumber

Set objWord = GetObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObjects = objWord.EmailOptions.EmailSignature

Set objSignatureEntries = objWordSignatureObjects.EmailSignatureEntries

objSelection.TypeText strName & ", " & strTitle
objSelection.TypeParagraph()
objSelection.TypeText strDepartment
objSelection.TypeParagraph()
objSelection.TypeText strCompany
objSelection.TypeParagraph()
objSelection.TypeText strPhone

Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD Signature", objSelection
objSignatureObjects.NewMessageSignature = "AD Signature"
objSignatureObjects.ReplyMessageSignature = "AD Signature"

objDoc.Save = True
objWord.Quit
Author
25 Sep 2006 11:46 AM
Sue Mosher [MVP-Outlook]
The script doesn't need to be set up in Outlook. As designed, it needs to be run once, as from a login script. It seems to have a few errors, though. Try this version instead:

On Error Resume Next

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

strName = objUser.FullName
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.TelephoneNumber

Set objWord = GetObject(, "Word.Application")
If objWord Is Nothing Then
    Set objWord = CreateObject("Word.Application")
    blnWeOpenedWord = True
End If
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObjects = objWord.EmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries

objSelection.TypeText strName & ", " & strTitle
objSelection.TypeParagraph
objSelection.TypeText strDepartment
objSelection.TypeParagraph
objSelection.TypeText strCompany
objSelection.TypeParagraph
objSelection.TypeText strPhone

Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD Signature", objSelection
objSignatureObjects.NewMessageSignature = "AD Signature"
objSignatureObjects.ReplyMessageSignature = "AD Signature"

objDoc.Close 0
If blnWeOpenedWord Then
    objWord.Quit
End If

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
"benb" <b***@discussions.microsoft.com> wrote in message news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
> Hi,
>
> In this months TechNet magazine, there is a couple of pages on scripting
> signatures in outlook. One of the sample scripts is a vbscript that queries
> active directory, pulls out the user info and then inserts it as a signature.
> However the article doesn't say how to set this script up in outlook. I've
> tried just adding the script to a signature, but when you insert the
> signature it just displays the script as text. How do I assign the script to
> the signature so that it will work correctly?
>
Author
25 Sep 2006 3:09 PM
benb
Hi Sue,

That worked great, thank you!

I've managed to get it to pull additional info like email address, and
mobile number, and add formatting using objSelection.Font.Name = "Arial" &
objSelection.Font.Size = "10".
However, I was wondering if you knew of a way to insert just a line break,
rather than a whole new paragraph? The trouble is that using
"objSelection.TypeParagraph" the signature comes out with:

===============
Joe Bloggs

IT Department

My Company

Tel: (1234) 123456
==================
I'd like to format it like this:
==================
Joe Bloggs
IT Department
My Company
Tel: (1234) 123456
==================

Thanks for you're help.

Ben

"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:eMtSsvJ4GHA.1300@TK2MSFTNGP05.phx.gbl...
The script doesn't need to be set up in Outlook. As designed, it needs to be
run once, as from a login script. It seems to have a few errors, though. Try
this version instead:

On Error Resume Next

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

strName = objUser.FullName
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.TelephoneNumber

Set objWord = GetObject(, "Word.Application")
If objWord Is Nothing Then
    Set objWord = CreateObject("Word.Application")
    blnWeOpenedWord = True
End If
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObjects = objWord.EmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries

objSelection.TypeText strName & ", " & strTitle
objSelection.TypeParagraph
objSelection.TypeText strDepartment
objSelection.TypeParagraph
objSelection.TypeText strCompany
objSelection.TypeParagraph
objSelection.TypeText strPhone

Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD Signature", objSelection
objSignatureObjects.NewMessageSignature = "AD Signature"
objSignatureObjects.ReplyMessageSignature = "AD Signature"

objDoc.Close 0
If blnWeOpenedWord Then
    objWord.Quit
End If

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
"benb" <b***@discussions.microsoft.com> wrote in message
news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
> Hi,
>
> In this months TechNet magazine, there is a couple of pages on scripting
> signatures in outlook. One of the sample scripts is a vbscript that
> queries
> active directory, pulls out the user info and then inserts it as a
> signature.
> However the article doesn't say how to set this script up in outlook. I've
> tried just adding the script to a signature, but when you insert the
> signature it just displays the script as text. How do I assign the script
> to
> the signature so that it will work correctly?
>
Author
25 Sep 2006 3:35 PM
Sue Mosher [MVP-Outlook]
You should be able to just build one string and use vbCR wherever you want a line break, then insert it with one TypeText statement.

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
"benb" <benblackmore@nospam.postalias> wrote in message news:e9pOWSL4GHA.1256@TK2MSFTNGP02.phx.gbl...
> Hi Sue,
>
> That worked great, thank you!
>
> I've managed to get it to pull additional info like email address, and
> mobile number, and add formatting using objSelection.Font.Name = "Arial" &
> objSelection.Font.Size = "10".
> However, I was wondering if you knew of a way to insert just a line break,
> rather than a whole new paragraph? The trouble is that using
> "objSelection.TypeParagraph" the signature comes out with:
>
> ===============
> Joe Bloggs
>
> IT Department
>
> My Company
>
> Tel: (1234) 123456
> ==================
> I'd like to format it like this:
> ==================
> Joe Bloggs
> IT Department
> My Company
> Tel: (1234) 123456
> ==================
>
> Thanks for you're help.
>
> Ben
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:eMtSsvJ4GHA.1300@TK2MSFTNGP05.phx.gbl...
> The script doesn't need to be set up in Outlook. As designed, it needs to be
> run once, as from a login script. It seems to have a few errors, though. Try
> this version instead:
>
> On Error Resume Next
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strUser = objSysInfo.UserName
> Set objUser = GetObject("LDAP://" & strUser)
>
> strName = objUser.FullName
> strTitle = objUser.Title
> strDepartment = objUser.Department
> strCompany = objUser.Company
> strPhone = objUser.TelephoneNumber
>
> Set objWord = GetObject(, "Word.Application")
> If objWord Is Nothing Then
>    Set objWord = CreateObject("Word.Application")
>    blnWeOpenedWord = True
> End If
> Set objDoc = objWord.Documents.Add()
> Set objSelection = objWord.Selection
>
> Set objEmailOptions = objWord.EmailOptions
> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>
> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>
> objSelection.TypeText strName & ", " & strTitle
> objSelection.TypeParagraph
> objSelection.TypeText strDepartment
> objSelection.TypeParagraph
> objSelection.TypeText strCompany
> objSelection.TypeParagraph
> objSelection.TypeText strPhone
>
> Set objSelection = objDoc.Range()
>
> objSignatureEntries.Add "AD Signature", objSelection
> objSignatureObjects.NewMessageSignature = "AD Signature"
> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>
> objDoc.Close 0
> If blnWeOpenedWord Then
>    objWord.Quit
> End If
>
> "benb" <b***@discussions.microsoft.com> wrote in message
> news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
>> Hi,
>>
>> In this months TechNet magazine, there is a couple of pages on scripting
>> signatures in outlook. One of the sample scripts is a vbscript that
>> queries
>> active directory, pulls out the user info and then inserts it as a
>> signature.
>> However the article doesn't say how to set this script up in outlook. I've
>> tried just adding the script to a signature, but when you insert the
>> signature it just displays the script as text. How do I assign the script
>> to
>> the signature so that it will work correctly?
>>
>
>
Author
25 Sep 2006 6:21 PM
ravelo.carlos
This script didn't work for me!!!

I am trying to get it to work and I cant, it opens word, adds the text,
but doesnt' add the signature :(


On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

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

strName = ObjUser.FullName



Set objWord = CreateObject("Word.Application")
objWord.Visible = True

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.TypeText strName
objSelection.TypeParagraph()

objDoc.Select

Set objEmailSign = objWord.EmailOptions.EmailSignature

Set objRange = objDoc.Paragraphs(1).Range

objEmailSign.EmailSignatureEntries.Add "AD Signature", objRange

With objEmailSign
    .NewMessageSignature = "AD Signature"
    .ReplyMessageSignature = "AD Signature"
End With


objDoc.Saved = True

rem objWord.Quit
Author
26 Sep 2006 8:17 AM
benb
Use the script that Sue supplied in her reply above, it worked perfectly for
me!

<ravelo.car***@gmail.com> wrote in message
Show quoteHide quote
news:1159208512.637705.187180@e3g2000cwe.googlegroups.com...
> This script didn't work for me!!!
>
> I am trying to get it to work and I cant, it opens word, adds the text,
> but doesnt' add the signature :(
>
>
> On Error Resume Next
>
> Set objSysInfo = CreateObject("ADSystemInfo")
>
> strUser = objSysInfo.Username
> Set objUser = GetObject("LDAP://" & strUser)
>
> strName = ObjUser.FullName
>
>
>
> Set objWord = CreateObject("Word.Application")
> objWord.Visible = True
>
> Set objDoc = objWord.Documents.Add()
> Set objSelection = objWord.Selection
> objSelection.TypeText strName
> objSelection.TypeParagraph()
>
> objDoc.Select
>
> Set objEmailSign = objWord.EmailOptions.EmailSignature
>
> Set objRange = objDoc.Paragraphs(1).Range
>
> objEmailSign.EmailSignatureEntries.Add "AD Signature", objRange
>
> With objEmailSign
>    .NewMessageSignature = "AD Signature"
>    .ReplyMessageSignature = "AD Signature"
> End With
>
>
> objDoc.Saved = True
>
> rem objWord.Quit
>
Author
26 Sep 2006 9:17 AM
benb
Hi Sue,

vbCR & TypeParagraph work fine if the email is written in plain or rich
text, however in HTML it always returns a new full new paragraph. I guess I
could use '<br>', at the end of each line for HTML, but then if the user
doesn't have HTML set as default, wouldn't it end up inserting <br> as text,
so I'd end up with "John Doe<br>Manager<br>IT Department<br>".
I need something that will give a line feed in plain text, rich text or
html, or maybe I could force everyone to use either Rich text, or HTML,
possibly add a section to the script, to set the outlook default!?

Thanks

Ben


"Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
news:eike9mL4GHA.4924@TK2MSFTNGP05.phx.gbl...
You should be able to just build one string and use vbCR wherever you want a
line break, then insert it with one TypeText statement.

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
"benb" <benblackmore@nospam.postalias> wrote in message
news:e9pOWSL4GHA.1256@TK2MSFTNGP02.phx.gbl...
> Hi Sue,
>
> That worked great, thank you!
>
> I've managed to get it to pull additional info like email address, and
> mobile number, and add formatting using objSelection.Font.Name = "Arial" &
> objSelection.Font.Size = "10".
> However, I was wondering if you knew of a way to insert just a line break,
> rather than a whole new paragraph? The trouble is that using
> "objSelection.TypeParagraph" the signature comes out with:
>
> ===============
> Joe Bloggs
>
> IT Department
>
> My Company
>
> Tel: (1234) 123456
> ==================
> I'd like to format it like this:
> ==================
> Joe Bloggs
> IT Department
> My Company
> Tel: (1234) 123456
> ==================
>
> Thanks for you're help.
>
> Ben
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:eMtSsvJ4GHA.1300@TK2MSFTNGP05.phx.gbl...
> The script doesn't need to be set up in Outlook. As designed, it needs to
> be
> run once, as from a login script. It seems to have a few errors, though.
> Try
> this version instead:
>
> On Error Resume Next
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strUser = objSysInfo.UserName
> Set objUser = GetObject("LDAP://" & strUser)
>
> strName = objUser.FullName
> strTitle = objUser.Title
> strDepartment = objUser.Department
> strCompany = objUser.Company
> strPhone = objUser.TelephoneNumber
>
> Set objWord = GetObject(, "Word.Application")
> If objWord Is Nothing Then
>    Set objWord = CreateObject("Word.Application")
>    blnWeOpenedWord = True
> End If
> Set objDoc = objWord.Documents.Add()
> Set objSelection = objWord.Selection
>
> Set objEmailOptions = objWord.EmailOptions
> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>
> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>
> objSelection.TypeText strName & ", " & strTitle
> objSelection.TypeParagraph
> objSelection.TypeText strDepartment
> objSelection.TypeParagraph
> objSelection.TypeText strCompany
> objSelection.TypeParagraph
> objSelection.TypeText strPhone
>
> Set objSelection = objDoc.Range()
>
> objSignatureEntries.Add "AD Signature", objSelection
> objSignatureObjects.NewMessageSignature = "AD Signature"
> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>
> objDoc.Close 0
> If blnWeOpenedWord Then
>    objWord.Quit
> End If
>
> "benb" <b***@discussions.microsoft.com> wrote in message
> news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
>> Hi,
>>
>> In this months TechNet magazine, there is a couple of pages on scripting
>> signatures in outlook. One of the sample scripts is a vbscript that
>> queries
>> active directory, pulls out the user info and then inserts it as a
>> signature.
>> However the article doesn't say how to set this script up in outlook.
>> I've
>> tried just adding the script to a signature, but when you insert the
>> signature it just displays the script as text. How do I assign the script
>> to
>> the signature so that it will work correctly?
>>
>
>
Author
26 Sep 2006 1:42 PM
Sue Mosher [MVP-Outlook]
<br> would never work in a Word document because it means text, not an HTML tag, to the Word object model.

Running the Word macro recorder for the time it takes to type a line, a line break, and another line suggests that Chr(11) is what you're looking for.

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
"benb" <benblackmore@nospam.postalias> wrote in message news:udZSWyU4GHA.1196@TK2MSFTNGP02.phx.gbl...
> Hi Sue,
>
> vbCR & TypeParagraph work fine if the email is written in plain or rich
> text, however in HTML it always returns a new full new paragraph. I guess I
> could use '<br>', at the end of each line for HTML, but then if the user
> doesn't have HTML set as default, wouldn't it end up inserting <br> as text,
> so I'd end up with "John Doe<br>Manager<br>IT Department<br>".
> I need something that will give a line feed in plain text, rich text or
> html, or maybe I could force everyone to use either Rich text, or HTML,
> possibly add a section to the script, to set the outlook default!?
>
> Thanks
>
> Ben
>
>
> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
> news:eike9mL4GHA.4924@TK2MSFTNGP05.phx.gbl...
> You should be able to just build one string and use vbCR wherever you want a
> line break, then insert it with one TypeText statement.
>
> "benb" <benblackmore@nospam.postalias> wrote in message
> news:e9pOWSL4GHA.1256@TK2MSFTNGP02.phx.gbl...
>> Hi Sue,
>>
>> That worked great, thank you!
>>
>> I've managed to get it to pull additional info like email address, and
>> mobile number, and add formatting using objSelection.Font.Name = "Arial" &
>> objSelection.Font.Size = "10".
>> However, I was wondering if you knew of a way to insert just a line break,
>> rather than a whole new paragraph? The trouble is that using
>> "objSelection.TypeParagraph" the signature comes out with:
>>
>> ===============
>> Joe Bloggs
>>
>> IT Department
>>
>> My Company
>>
>> Tel: (1234) 123456
>> ==================
>> I'd like to format it like this:
>> ==================
>> Joe Bloggs
>> IT Department
>> My Company
>> Tel: (1234) 123456
>> ==================
>>
>> Thanks for you're help.
>>
>> Ben
>>
>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message
>> news:eMtSsvJ4GHA.1300@TK2MSFTNGP05.phx.gbl...
>> The script doesn't need to be set up in Outlook. As designed, it needs to
>> be
>> run once, as from a login script. It seems to have a few errors, though.
>> Try
>> this version instead:
>>
>> On Error Resume Next
>>
>> Set objSysInfo = CreateObject("ADSystemInfo")
>> strUser = objSysInfo.UserName
>> Set objUser = GetObject("LDAP://" & strUser)
>>
>> strName = objUser.FullName
>> strTitle = objUser.Title
>> strDepartment = objUser.Department
>> strCompany = objUser.Company
>> strPhone = objUser.TelephoneNumber
>>
>> Set objWord = GetObject(, "Word.Application")
>> If objWord Is Nothing Then
>>    Set objWord = CreateObject("Word.Application")
>>    blnWeOpenedWord = True
>> End If
>> Set objDoc = objWord.Documents.Add()
>> Set objSelection = objWord.Selection
>>
>> Set objEmailOptions = objWord.EmailOptions
>> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>>
>> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>>
>> objSelection.TypeText strName & ", " & strTitle
>> objSelection.TypeParagraph
>> objSelection.TypeText strDepartment
>> objSelection.TypeParagraph
>> objSelection.TypeText strCompany
>> objSelection.TypeParagraph
>> objSelection.TypeText strPhone
>>
>> Set objSelection = objDoc.Range()
>>
>> objSignatureEntries.Add "AD Signature", objSelection
>> objSignatureObjects.NewMessageSignature = "AD Signature"
>> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>>
>> objDoc.Close 0
>> If blnWeOpenedWord Then
>>    objWord.Quit
>> End If
>>
>> "benb" <b***@discussions.microsoft.com> wrote in message
>> news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
>>> Hi,
>>>
>>> In this months TechNet magazine, there is a couple of pages on scripting
>>> signatures in outlook. One of the sample scripts is a vbscript that
>>> queries
>>> active directory, pulls out the user info and then inserts it as a
>>> signature.
>>> However the article doesn't say how to set this script up in outlook.
>>> I've
>>> tried just adding the script to a signature, but when you insert the
>>> signature it just displays the script as text. How do I assign the script
>>> to
>>> the signature so that it will work correctly?
>>>
>>
>>
>
>
Author
10 Oct 2006 8:43 PM
wmcollis
How do I format the signature to set the first line bold, italic,
arial, size 10 and all of the other lines as italic, arial, size 10?
i tried to add the line at the
objSelection.Font.Name = "Arial" & objSelection.Font.Size = "10" &
objSelection.Font.bold = True
but it does not work.

How do I format the signature?
Sue Mosher [MVP-Outlook] wrote:
Show quoteHide quote
> The script doesn't need to be set up in Outlook. As designed, it needs to be run once, as from a login script. It seems to have a few errors, though. Try this version instead:
>
> On Error Resume Next
>
> Set objSysInfo = CreateObject("ADSystemInfo")
> strUser = objSysInfo.UserName
> Set objUser = GetObject("LDAP://" & strUser)
>
> strName = objUser.FullName
> strTitle = objUser.Title
> strDepartment = objUser.Department
> strCompany = objUser.Company
> strPhone = objUser.TelephoneNumber
>
> Set objWord = GetObject(, "Word.Application")
> If objWord Is Nothing Then
>     Set objWord = CreateObject("Word.Application")
>     blnWeOpenedWord = True
> End If
> Set objDoc = objWord.Documents.Add()
> Set objSelection = objWord.Selection
>
> Set objEmailOptions = objWord.EmailOptions
> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>
> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>
> objSelection.TypeText strName & ", " & strTitle
> objSelection.TypeParagraph
> objSelection.TypeText strDepartment
> objSelection.TypeParagraph
> objSelection.TypeText strCompany
> objSelection.TypeParagraph
> objSelection.TypeText strPhone
>
> Set objSelection = objDoc.Range()
>
> objSignatureEntries.Add "AD Signature", objSelection
> objSignatureObjects.NewMessageSignature = "AD Signature"
> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>
> objDoc.Close 0
> If blnWeOpenedWord Then
>     objWord.Quit
> End If
>
> --
> Sue Mosher, Outlook MVP
>    Author of Configuring Microsoft Outlook 2003
>      http://www.turtleflock.com/olconfig/index.htm
>    and Microsoft Outlook Programming - Jumpstart for
>      Administrators, Power Users, and Developers
>      http://www.outlookcode.com/jumpstart.aspx
>
> "benb" <b***@discussions.microsoft.com> wrote in message news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
> > Hi,
> >
> > In this months TechNet magazine, there is a couple of pages on scripting
> > signatures in outlook. One of the sample scripts is a vbscript that queries
> > active directory, pulls out the user info and then inserts it as a signature.
> > However the article doesn't say how to set this script up in outlook. I've
> > tried just adding the script to a signature, but when you insert the
> > signature it just displays the script as text. How do I assign the script to
> > the signature so that it will work correctly?
> >
Author
10 Oct 2006 8:49 PM
Sue Mosher [MVP-Outlook]
The easiest way is to turn on Word's macro recorder while you type the text and format it, then incorporate that macro code into the existing script.

--
Sue Mosher, Outlook MVP
   Author of Configuring Microsoft Outlook 2003
     http://www.turtleflock.com/olconfig/index.htm
   and Microsoft Outlook Programming - Jumpstart for
     Administrators, Power Users, and Developers
     http://www.outlookcode.com/jumpstart.aspx

Show quoteHide quote
<wmcol***@gmail.com> wrote in message news:1160512993.689622.48190@b28g2000cwb.googlegroups.com...
> How do I format the signature to set the first line bold, italic,
> arial, size 10 and all of the other lines as italic, arial, size 10?
> i tried to add the line at the
> objSelection.Font.Name = "Arial" & objSelection.Font.Size = "10" &
> objSelection.Font.bold = True
> but it does not work.
>
> How do I format the signature?
> Sue Mosher [MVP-Outlook] wrote:
>> The script doesn't need to be set up in Outlook. As designed, it needs to be run once, as from a login script. It seems to have a few errors, though. Try this version instead:
>>
>> On Error Resume Next
>>
>> Set objSysInfo = CreateObject("ADSystemInfo")
>> strUser = objSysInfo.UserName
>> Set objUser = GetObject("LDAP://" & strUser)
>>
>> strName = objUser.FullName
>> strTitle = objUser.Title
>> strDepartment = objUser.Department
>> strCompany = objUser.Company
>> strPhone = objUser.TelephoneNumber
>>
>> Set objWord = GetObject(, "Word.Application")
>> If objWord Is Nothing Then
>>     Set objWord = CreateObject("Word.Application")
>>     blnWeOpenedWord = True
>> End If
>> Set objDoc = objWord.Documents.Add()
>> Set objSelection = objWord.Selection
>>
>> Set objEmailOptions = objWord.EmailOptions
>> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>>
>> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>>
>> objSelection.TypeText strName & ", " & strTitle
>> objSelection.TypeParagraph
>> objSelection.TypeText strDepartment
>> objSelection.TypeParagraph
>> objSelection.TypeText strCompany
>> objSelection.TypeParagraph
>> objSelection.TypeText strPhone
>>
>> Set objSelection = objDoc.Range()
>>
>> objSignatureEntries.Add "AD Signature", objSelection
>> objSignatureObjects.NewMessageSignature = "AD Signature"
>> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>>
>> objDoc.Close 0
>> If blnWeOpenedWord Then
>>     objWord.Quit
>> End If

>>
>> "benb" <b***@discussions.microsoft.com> wrote in message news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
>> > Hi,
>> >
>> > In this months TechNet magazine, there is a couple of pages on scripting
>> > signatures in outlook. One of the sample scripts is a vbscript that queries
>> > active directory, pulls out the user info and then inserts it as a signature.
>> > However the article doesn't say how to set this script up in outlook. I've
>> > tried just adding the script to a signature, but when you insert the
>> > signature it just displays the script as text. How do I assign the script to
>> > the signature so that it will work correctly?
>> >
>
Author
16 Oct 2006 9:14 AM
benb
Here's an example of ours, which changes font colour and makes it bold mid
way through:

objSelectionNew.Font.Name = "Arial"    'set font
objSelectionNew.Font.Size = "10"          'set size

objSelectionNew.TypeText strName      'Users Full Name
if strDescription Then
objSelectionNew.TypeText ", " & strDescription     'If user has description
set in AD display (we use this field for certifications)
end if
objSelectionNew.TypeText Chr(11) & strTitle     'Users title (Managing
Director, Administrator etc)
objSelectionNew.TypeParagraph
objSelectionNew.Font.Color = vbBlue        'Set font colour to blue
objSelectionNew.Font.Bold = True             'Set font to bold
objSelectionNew.TypeText "Our Company"  'Our company name
objSelectionNew.Font.Color = vbBlack        'Set font back to black
objSelectionNew.Font.Bold = False             'Un set bold
objSelectionNew.TypeParagraph
objSelectionNew.TypeText "Tel:" & vbTab & strPhone & Chr(11)  'Users DDI
phone number
if objUser.Mobile Then
objSelectionNew.TypeText "Mobile:" & vbTab & strMobile & Chr(11)    'If user
has a mobile then display
end if
objSelectionNew.TypeText "E-mail:" & vbTab & strEmail & Chr(11)
'Users email address
objSelectionNew.TypeText "www.ourdomain.com" & Chr(11) & Chr(11)
'Company website

This all results in the following signature

Ben B, MCSE 2000, MCSE 2003
PC & Network Support Administrator
Our Company
Tel: +44 (0)1234 123456
Mobile: +44 (0)77123456
E-mail: benb@nospam.com
www.ourdomain.com

HTH

Ben


<wmcol***@gmail.com> wrote in message
Show quoteHide quote
news:1160512993.689622.48190@b28g2000cwb.googlegroups.com...
> How do I format the signature to set the first line bold, italic,
> arial, size 10 and all of the other lines as italic, arial, size 10?
> i tried to add the line at the
> objSelection.Font.Name = "Arial" & objSelection.Font.Size = "10" &
> objSelection.Font.bold = True
> but it does not work.
>
> How do I format the signature?
> Sue Mosher [MVP-Outlook] wrote:
>> The script doesn't need to be set up in Outlook. As designed, it needs to
>> be run once, as from a login script. It seems to have a few errors,
>> though. Try this version instead:
>>
>> On Error Resume Next
>>
>> Set objSysInfo = CreateObject("ADSystemInfo")
>> strUser = objSysInfo.UserName
>> Set objUser = GetObject("LDAP://" & strUser)
>>
>> strName = objUser.FullName
>> strTitle = objUser.Title
>> strDepartment = objUser.Department
>> strCompany = objUser.Company
>> strPhone = objUser.TelephoneNumber
>>
>> Set objWord = GetObject(, "Word.Application")
>> If objWord Is Nothing Then
>>     Set objWord = CreateObject("Word.Application")
>>     blnWeOpenedWord = True
>> End If
>> Set objDoc = objWord.Documents.Add()
>> Set objSelection = objWord.Selection
>>
>> Set objEmailOptions = objWord.EmailOptions
>> Set objSignatureObjects = objWord.EmailOptions.EmailSignature
>>
>> Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
>>
>> objSelection.TypeText strName & ", " & strTitle
>> objSelection.TypeParagraph
>> objSelection.TypeText strDepartment
>> objSelection.TypeParagraph
>> objSelection.TypeText strCompany
>> objSelection.TypeParagraph
>> objSelection.TypeText strPhone
>>
>> Set objSelection = objDoc.Range()
>>
>> objSignatureEntries.Add "AD Signature", objSelection
>> objSignatureObjects.NewMessageSignature = "AD Signature"
>> objSignatureObjects.ReplyMessageSignature = "AD Signature"
>>
>> objDoc.Close 0
>> If blnWeOpenedWord Then
>>     objWord.Quit
>> End If
>>
>> --
>> Sue Mosher, Outlook MVP
>>    Author of Configuring Microsoft Outlook 2003
>>      http://www.turtleflock.com/olconfig/index.htm
>>    and Microsoft Outlook Programming - Jumpstart for
>>      Administrators, Power Users, and Developers
>>      http://www.outlookcode.com/jumpstart.aspx
>>
>> "benb" <b***@discussions.microsoft.com> wrote in message
>> news:CA6A43E7-3483-4904-81B8-922E88C0956D@microsoft.com...
>> > Hi,
>> >
>> > In this months TechNet magazine, there is a couple of pages on
>> > scripting
>> > signatures in outlook. One of the sample scripts is a vbscript that
>> > queries
>> > active directory, pulls out the user info and then inserts it as a
>> > signature.
>> > However the article doesn't say how to set this script up in outlook.
>> > I've
>> > tried just adding the script to a signature, but when you insert the
>> > signature it just displays the script as text. How do I assign the
>> > script to
>> > the signature so that it will work correctly?
>> >
>
Author
18 Oct 2006 11:10 AM
Scuzzy
This was just the script I was looking for. And it works great!
There's just one thing that I can't seem to find.

I would to display the email address in the signature as a link
(mailto:) I tried simply putting:

objSelection.TypeText "<a href=""mailto:" & strEmail & """>" & strEmail
& "</a>"

....But that will give me the whole string in text format.
Is there a way to get the email address (or any address) to display as
a clickable link?
Author
24 Oct 2006 10:17 AM
benb
Scuzzy,

I don't think it's possible in plain/rich text. If you try and insert a
clickable mail link manually you can't do it, it only seems to recognise
www....
From what I can see, you can only do this using html, then you would use
mailto: which should work!

Ben

Show quoteHide quote
"Scuzzy" <scu***@planet.nl> wrote in message
news:1161169803.352156.87890@k70g2000cwa.googlegroups.com...
> This was just the script I was looking for. And it works great!
> There's just one thing that I can't seem to find.
>
> I would to display the email address in the signature as a link
> (mailto:) I tried simply putting:
>
> objSelection.TypeText "<a href=""mailto:" & strEmail & """>" & strEmail
> & "</a>"
>
> ...But that will give me the whole string in text format.
> Is there a way to get the email address (or any address) to display as
> a clickable link?
>
Author
25 Jan 2007 5:30 PM
Morten Leth
objSelection.Hyperlinks.Add objSelection.range, "mailto:" & strEmail, , , strEmail

hope it will solve your problem.. :D

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com