#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Question Signature Script


    I have modified the dynamic signature script bellow and it works great except for one part.
    I need the script to assign the logo picture based on what office the user is in and the If/then statement does not work. i know i am doing something wrong but i cannot find it in the code. may some look over it please.

    Code:
    '==========================
    '
    ' ###############  Script that creates a standard company signature for all users (in a corporate environment); pulling data from Active Directory - dynamic logo insertion depending on department field if needed.
    '
    ' Neeshan Peters
    '
    ' 
    '
    ' 12-17-2011.
    '
    '===========================
    
    
    On Error Resume Next
    Set objSysInfo = CreateObject("ADSystemInfo")
    
     
    
    ' ########### This section connects to Active Directory as the currently logged on user
    
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" & strUser)  
    
     
    
    ' ########### This section sets up the variables we want to call in the script (items on the left; whereas the items on the right are the active directory database field names) - ie strVariablename = objuser.ad.databasename
    strSignatureName = "Signature Name"
    strLogoPath = "\\iclkyfs01\data\signatures\icl_logo_email.jpg"
    strGiven = objuser.givenName
    strSurname = objuser.sn
    strAddress1 = objUser.streetAddress
    strAddress1EXT = objUser.postofficebox
    strAddress2 = objuser.l
    strAddress3 = objuser.st
    strPostcode = objuser.postalcode
    strExt = objuser.homephone
    strTitle = objUser.Title
    strEmail =objuser.mail
    strCompany = objUser.Company
    strPhone = objUser.telephoneNumber
    strFax = objUser.facsimileTelephoneNumber
    strMobile = objuser.mobile
    strOffice = objuser.Office
    
    REM strWeb = objuser.wWWHomePage
    REM strNotes = objuser.info
    REM strDepartment = objUser.Department
    REM strIP = objuser.ipPhone
    REM strEmailTEXT = "Email: "
    REM strCountry = objuser.c
    
    
    ' ### Sets up word template
    
    Set objWord = CreateObject("Word.Application")
    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection
    
    objSelection.Style = "No Spacing"
    Set objEmailOptions = objWord.EmailOptions
    Set objSignatureObject = objEmailOptions.EmailSignature
    Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
    
    '### creates a table in the word document with three rows and one columns
    objselection.TypeText Chr(11)
      
    Const Number_of_rows = 2
    Const Number_of_columns = 1
    Const END_OF_STORY = 1
    
    objSelection.TypeParagraph()
    Set objRange = objSelection.Range
    objDoc.Tables.Add objRange, number_of_rows, number_of_columns 
    Set objTable = objDoc.Tables(1)
    objTable.AutoFitBehavior(1)
    
    
    Set objCell = objTable.Cell(1, 1)
    Set objCellRange = objCell.Range
    objCell.Select
    
    '### Set up the formatting for the name
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 11
    objSelection.Font.Bold = True
    objSelection.Font.Color = RGB (180,151,090)
    
    '### Type the name
    objSelection.TypeText     strGiven & " " & strSurname & Chr(11)
    
    '### Set up the formatting for the title
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10.5
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (000,000,000)
    
    '### Type the title
    objSelection.TypeText      strTitle & Chr(11) & Chr(11)
    
    
    '### Sets up the second cell with the logo inside
    Set objCell = objTable.Cell(2, 1)
    Set objCellRange = objCell.Range
    objSelection.Range = objCell.Range
    
    If (strOffice) = "2" Then 
                 objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\hottropics.jpg") 
    ElseIf (strOffice = "20") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-time.jpg")
    ElseIf (strOffice = "22") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-jewellers.jpg")
    ElseIf (strOffice = "32") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\john-hardy.jpg")
    ElseIf (strOffice = "41") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\watchme_sunglass.jpg")
    ElseIf (strOffice = "4") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-jewellers.jpg")
    ElseIf (strOffice = "5") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\de-bag-man.jpg")
    ElseIf (strOffice = "10") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\watchme_sunglass.jpg")
    ElseIf (strOffice = "13") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\pandora.jpg")
    ElseIf (strOffice = "14") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-treasures.jpg")
    ElseIf (strOffice = "19") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\ammolite-by-the-bay.jpg")
    ElseIf (strOffice = "23") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\tropical-trader.jpg")
    ElseIf (strOffice = "24") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\churchill's-cigars.jpg")
    ElseIf (strOffice = "27") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\Diamonds-direct")
    ElseIf (strOffice = "29") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\Pirates Grotto.jpg")
    ElseIf (strOffice = "30") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\swarovski.jpg")
    ElseIf (strOffice = "31") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-time.jpg")
    ElseIf (strOffice = "15") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\cheeky-monkey.jpg")
    ElseIf (strOffice = "28") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\landmark.jpg")
    ElseIf (strOffice = "42") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\mansion.jpg")
    ElseIf (strOffice = "43") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\pandora.jpg")
    ElseIf (strOffice = "39") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\watchme_sunglass.jpg")
    ElseIf (strOffice = "25") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\churchill's-cigars.jpg")
    ElseIf (strOffice = "26") Then 
            objSelection.InlineShapes.AddPicture("\\iclkyfs01\data\signatures\island-time.jpg")
    Else 
            objSelection.InlineShapes.AddPicture(strLogoPath)
     
    End If 
    
    
    
    'Set objCell = objTable.Cell(3, 1)
    'Set objCellRange = objCell.Range
    'objCell.Select
            
    '### Set up the formatting for the body
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    
    objSelection.TypeText  Chr(11) &_
                            "P: " 
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (000,000,000)
    
    
    objSelection.TypeText  strPhone & " "
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    
    objSelection.TypeText " F: "
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (000,000,000)
    
    
    objSelection.TypeText   strFax & Chr(11) 
                            
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    
    objSelection.TypeText "E: "
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (000,000,000)
    
    
    objSelection.TypeText   strEmail & " "
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    
    objSelection.TypeText " W: "
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (000,000,000)
    
    
    objSelection.TypeText   strCompany & Chr(11) &_
                             strAddress1 &  Chr(11)
    
    '### Set up the formatting for the Guarantee
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    '### Type the name
    objSelection.TypeText     "90 DAY GLOBAL MONEY BACK"
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 11
    objSelection.Font.Bold = True
    objSelection.Font.Color = RGB (180,151,090)
    
    '### Type the name
    objSelection.TypeText     " GOLD STAR"
    
    objSelection.Font.Name = "Trebuchet MS"
    objSelection.Font.Size = 10
    objSelection.Font.Bold = False
    objSelection.Font.Color = RGB (180,151,090)
    
    '### Type the name
    objSelection.TypeText     " GUARANTEE"
                                
    
    
    '### set the signature up as strSignatureName and tell outlook to use it as default
    Set objSelection = objDoc.Range()
    objSignatureEntries.Add strSignatureName, objSelection
    objSignatureObject.NewMessageSignature = strSignatureName
    objSignatureObject.ReplyMessageSignature = "(none)"
    
    '### save the signature
    objDoc.Saved = True
    
    objWord.Quit
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,449
    Rep Power
    4539
    Start by removing the on error resume next statement, you'll probably see a 'hidden' asp error that's causing your problem.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by Doug G
    Start by removing the on error resume next statement, you'll probably see a 'hidden' asp error that's causing your problem.
    I get the error Object doesn't support this property or method: 'objUser.Office'
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by direrayne
    I get the error Object doesn't support this property or method: 'objUser.Office'
    SOLVED

    I had to replace objUser.Office with objUser.physicalDeliveryOfficeName

    Thank you
  8. #5
  9. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,449
    Rep Power
    4539
    I'm glad you got it solved.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    7
    Rep Power
    0
    Thanks for solving our problem.

IMN logo majestic logo threadwatch logo seochat tools logo