Signature doing something weird

M

Matt

Hi all,

I have a little VBS script that runs from a GPO as part of the user's login
processing that automatically creates an Outlook signature based on
information extracted from their Active Directory account. The script itself
works fine and gives me entirely the expected results, except for two
things:

o The company logo is referenced from an external web site and placed
as the *very first* item on the signature, but when used in a new mail
message, two line spaces appear immediately above it. This happens across
every machine I have tested it on.
o When the spell checker is invoked, a nice little box pops up that
says "The spelling and grammar check is complete. Text marked with 'Do not
check spelling or grammar' was skipped". After examining the formatting
style of the paragraph, I note that "Do not check spelling or grammer" is
'half ticked' on the Language settings. By 'half ticked' I mean the grey
tick which indicates it inherits the setting from somewhere else. I've
pulled my hair out trying to clear this tick box programmatically but have
been unsuccessful.

Any assistance is most gratefully received!


For reference, here's the VBS script I'm using:

Code:
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
strEmail  = objUser.emailAddress

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

'
' Here I set style, override the font settings and explicitly clear the
NoProofing setting
'
objSelection.Style  = "Normal"
objSelection.Font.Name  = "Verdana"
objSelection.Font.Size  = 9
objSelection.NoProofing = False

'
' Here is where the image gets inserted - note nothing inserted before it
'
objSelection.InlineShapes.AddPicture "http://www.website.com/image.gif"
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText "Kind regards, "
objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Bold = true
objSelection.TypeText strName
objSelection.Font.Bold = false
objSelection.TypeParagraph()

objSelection.Font.Italic = true
objSelection.TypeText strTitle
objSelection.Font.Italic = false

objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText strCompany
objSelection.TypeParagraph()

Set objSelection = objDoc.Range()

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

objDoc.Saved = True
objWord.Quit
 
M

Matt

Is this the appropriate forum for this message or should I post elsewhere?

Thanks

Matt said:
Hi all,

I have a little VBS script that runs from a GPO as part of the user's
login processing that automatically creates an Outlook signature based on
information extracted from their Active Directory account. The script
itself works fine and gives me entirely the expected results, except for
two things:

o The company logo is referenced from an external web site and
placed as the *very first* item on the signature, but when used in a new
mail message, two line spaces appear immediately above it. This happens
across every machine I have tested it on.
o When the spell checker is invoked, a nice little box pops up that
says "The spelling and grammar check is complete. Text marked with 'Do not
check spelling or grammar' was skipped". After examining the formatting
style of the paragraph, I note that "Do not check spelling or grammer" is
'half ticked' on the Language settings. By 'half ticked' I mean the grey
tick which indicates it inherits the setting from somewhere else. I've
pulled my hair out trying to clear this tick box programmatically but have
been unsuccessful.

Any assistance is most gratefully received!


For reference, here's the VBS script I'm using:

Code:
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
strEmail  = objUser.emailAddress

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

'
' Here I set style, override the font settings and explicitly clear the
NoProofing setting
'
objSelection.Style  = "Normal"
objSelection.Font.Name  = "Verdana"
objSelection.Font.Size  = 9
objSelection.NoProofing = False

'
' Here is where the image gets inserted - note nothing inserted before it
'
objSelection.InlineShapes.AddPicture "http://www.website.com/image.gif"
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText "Kind regards, "
objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Bold = true
objSelection.TypeText strName
objSelection.Font.Bold = false
objSelection.TypeParagraph()

objSelection.Font.Italic = true
objSelection.TypeText strTitle
objSelection.Font.Italic = false

objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.TypeText strCompany
objSelection.TypeParagraph()

Set objSelection = objDoc.Range()

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

objDoc.Saved = True
objWord.Quit
 
B

Bob Buckland ?:-\)

Hi Matt,

From your description the install/login is working correctly, it's just the formatting result that is having an issue?

You may want to use the link below to also post to the Outlook VBA developer's group (even though you're using the VBS script) to
see if the folks there might recognize the issue. Be sure when posting there to also include the version of Outlook and Windows
(and Exchange if in play) you are working with.

=====================
Is this the appropriate forum for this message or should I post elsewhere?


Thanks >>
--
Please let us know if this has helped,

Bob Buckland ?:)
MS Office System Products MVP

LINKS
A. Specific newsgroup/discussion group mentioned in this message:
news://msnews.microsoft.com/microsoft.public.outlook.program_vba
or via browser:
http://microsoft.com/communities/newsgroups/en-us/?dg=microsoft.public.outlook.program_vba
B. MS Office Community discussion/newsgroups via Web Browser
http://microsoft.com/office/community/en-us/default.mspx
or
Microsoft hosted newsgroups via Outlook Express/newsreader
news://msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top