-
Text Alignment
Hello All,
This is my first post here and I'm sure this is a simple process but I'm just not hitting the nail on the head:
I'm new to Word VBA (and VBA in general) and I've been asked to generate an auto-signature for my companys' Outlook users, I've managed to find code on the Net and from trial and error and a LOT of googling, I've managed to throw a decent auto-signature piece of code together that runs during logon, however, there's only one problem I haven't been able to lick, text alignment. Basically, I want to align everything else in the signature to the right. Everything works properly except the alignment, it is based on code I found on Sue Moxer's Outlook site.
I've searched the forums here and nothing really stands out to me so I'm going to post the code here and hopefully someone can help:
The code:
[vba]
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strName = objUser.FullName
strTitle = objUser.Description
strCompany = "Company Name"
strAddress = "Company Address"
strCity = "Company City"
strPhone = "Company Phone"
strTollFree = "Company Toll Free Phone"
strFax = "Company Fax"
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.ParagraphFormat.Alignment = wdAlignParagraphRight
objSelection.TypeParagraph()
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = 10
objSelection.Font.Bold = True
objSelection.TypeText strName & chr(11)
objSelection.Font.Bold = False
objSelection.Font.Italic = True
objSelection.TypeText strTitle & chr(11)
objSelection.Font.Italic = False
objSelection.TypeText chr(11)
objSelection.InlineShapes.AddPicture "C:\Public\Clipart\email-sig-mall.jpg",
true, true
objSelection.TypeText & chr(11)
objSelection.Font.Size = 8
objSelection.TypeText strAddress & chr(11)
objSelection.TypeText strCity & chr(11)
objSelection.TypeText strPhone & chr(11)
objSelection.TypeText strTollFree & chr(11)
objSelection.TypeText strFax & chr(11)
Set objSelection = objDoc.Range()
objSignatureEntries.Add "AD Signature", objSelection
objSignatureObject.NewMessageSignature = "AD Signature"
objSignatureObject.ReplyMessageSignature = "AD Signature"
objDoc.Saved = True
objWord.Quit
[/vba]
Last edited by cw75cdn; 08-20-2008 at 03:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules