Announcement

Collapse
No announcement yet.

Skip if field is blank

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Skip if field is blank

    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

    Code:
    objSelection.TypeText "Direct Fax: " & strFax
    if it is not empty.

    Any pointers ?



    Full Script

    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
    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

  • #2
    Re: Skip if field is blank

    You just need an IF statement:

    Code:
     
    If strFax <> "" then
      objSelection.TypeText "Direct Fax: " & strFax
    End If
    If the strFax is NOT Blank (equal to "") then add the string.

    Hobie

    Comment


    • #3
      Re: Skip if field is blank

      Many thanks for the quick reply Hobie ! worked a treat

      Comment

      Working...
      X