Skip if field is blank
Home › Forums › Scripting › Windows Script Host › Skip if field is blank
- This topic has 2 replies, 2 voices, and was last updated 9 years, 9 months ago by
Hobie.
-
AuthorPosts
-
brian873MemberApr 19, 2011 at 8:41 am #154296Hi, 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
[/CODE]if it is not empty.
Any pointers ?
Full Script
[CODE]
On Error Resume NextSet 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.facsimileTelephoneNumberSet objWord = CreateObject(“Word.Application”)
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.SelectionSet objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignatureSet 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: ” & strFaxSet objSelection = objDoc.Range()
objSignatureEntries.Add “AD Signature”, objSelection
objSignatureObject.NewMessageSignature = “AD Signature”
objSignatureObject.ReplyMessageSignature = “AD Signature”objDoc.Saved = True
objWord.Quit
[/CODE][CODE]
objSelection.TypeText “Direct Fax: ” & strFax
[/CODE]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.facsimileTelephoneNumberSet objWord = CreateObject(“Word.Application”)
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.SelectionSet objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignatureSet 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: ” & strFaxSet objSelection = objDoc.Range()
objSignatureEntries.Add “AD Signature”, objSelection
objSignatureObject.NewMessageSignature = “AD Signature”
objSignatureObject.ReplyMessageSignature = “AD Signature”objDoc.Saved = True
objWord.Quit
[/CODE][CODE]
On Error Resume NextSet 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.facsimileTelephoneNumberSet objWord = CreateObject(“Word.Application”)
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.SelectionSet objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignatureSet 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: ” & strFaxSet objSelection = objDoc.Range()
objSignatureEntries.Add “AD Signature”, objSelection
objSignatureObject.NewMessageSignature = “AD Signature”
objSignatureObject.ReplyMessageSignature = “AD Signature”objDoc.Saved = True
objWord.Quit
[/CODE] -
AuthorPosts
You must be logged in to reply to this topic.