Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 27th, 2012, 09:40 AM
direrayne direrayne is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 3 direrayne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 20 sec
Reputation 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 

Reply With Quote
  #2  
Old January 27th, 2012, 01:08 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,235 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 27 m 16 sec
Reputation Power: 4445
Start by removing the on error resume next statement, you'll probably see a 'hidden' asp error that's causing your problem.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old January 27th, 2012, 01:49 PM
direrayne direrayne is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 3 direrayne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 20 sec
Reputation Power: 0
Quote:
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'

Reply With Quote
  #4  
Old January 27th, 2012, 03:19 PM
direrayne direrayne is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2012
Posts: 3 direrayne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 20 sec
Reputation Power: 0
Quote:
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

Reply With Quote
  #5  
Old January 27th, 2012, 06:28 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,235 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 27 m 16 sec
Reputation Power: 4445
I'm glad you got it solved.

Reply With Quote
  #6  
Old February 17th, 2012, 05:10 AM
johnhernandez johnhernandez is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 7 johnhernandez User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 36 m 3 sec
Reputation Power: 0
Thanks for solving our problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Signature Script

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap