Jump to content

Recommended Posts

Posted

Hi, I am looking for some help with a VB script I am trying to improve.

The script runs at logon and pulls out some AD information to create an email signature for the user in Outlook 2003. The script is working fine but I would now like to add in a check so if a field is blank, it does not include that section the in signature.

The issue is that not all users have fax numbers so I would like to check the fax and only include the line


objSelection.TypeText "Direct Fax: " & strFax

if it is not empty.

Any pointers ?

Full Script


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
strFax = objUser.facsimileTelephoneNumber

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"
objSelection.Font.Bold = True
objSelection.TypeParagraph()
objSelection.TypeText strName
objSelection.TypeParagraph()
objSelection.TypeText strTitle
objSelection.TypeParagraph()
objSelection.TypeText "Direct Dial: " & strPhone
objSelection.TypeParagraph()
objSelection.TypeText "Direct Fax: " & strFax

Set objSelection = objDoc.Range()

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

objDoc.Saved = True
objWord.Quit


Posted

Try addng This Code Before strFax Is Outputted


If strFax = "" Then
strFax = "No User Fax Number Was Found"
Else
strFax = strFax
End If objSelection.TypeText "Direct Fax: " & strFax

Posted


.....
objSelection.TypeParagraph()
if strFax <> "" then
objSelection.TypeText "Direct Fax: " & strFax
End If

Set objSelection = objDoc.Range()
......

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...