brian873 Posted April 19, 2011 Share Posted April 19, 2011 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 lineobjSelection.TypeText "Direct Fax: " & strFaxif it is not empty.Any pointers ?Full ScriptOn Error Resume NextSet objSysInfo = CreateObject("ADSystemInfo")strUser = objSysInfo.UserNameSet objUser = GetObject("LDAP://" & strUser)strName = objUser.FullNamestrTitle = objUser.TitlestrDepartment = objUser.DepartmentstrCompany = objUser.CompanystrPhone = objUser.telephoneNumberstrFax = objUser.facsimileTelephoneNumberSet objWord = CreateObject("Word.Application")Set objDoc = objWord.Documents.Add()Set objSelection = objWord.SelectionSet objEmailOptions = objWord.EmailOptionsSet objSignatureObject = objEmailOptions.EmailSignatureSet objSignatureEntries = objSignatureObject.EmailSignatureEntriesobjSelection.Font.Name = "Arial"objSelection.Font.Size = "10"objSelection.Font.Bold = TrueobjSelection.TypeParagraph()objSelection.TypeText strNameobjSelection.TypeParagraph()objSelection.TypeText strTitleobjSelection.TypeParagraph()objSelection.TypeText "Direct Dial: " & strPhoneobjSelection.TypeParagraph()objSelection.TypeText "Direct Fax: " & strFaxSet objSelection = objDoc.Range()objSignatureEntries.Add "AD Signature", objSelectionobjSignatureObject.NewMessageSignature = "AD Signature"objSignatureObject.ReplyMessageSignature = "AD Signature"objDoc.Saved = TrueobjWord.Quit Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 19, 2011 Share Posted April 19, 2011 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 Link to comment Share on other sites More sharing options...
IcemanND Posted April 20, 2011 Share Posted April 20, 2011 .....objSelection.TypeParagraph()if strFax <> "" then objSelection.TypeText "Direct Fax: " & strFaxEnd IfSet objSelection = objDoc.Range()...... Link to comment Share on other sites More sharing options...
brian873 Posted April 20, 2011 Author Share Posted April 20, 2011 Hi Guys, thanks for both your help !Thats it working fine for me now Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now