The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Visual Basic Programming
|
Signature Script
Discuss Signature Script in the Visual Basic Programming forum on Dev Shed. Signature Script Visual Basic Programming forum discussing VB specific programming information. Quickly prototype and build applications with this robust and simple language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 27th, 2012, 09:40 AM
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 3
Time spent in forums: 11 m 20 sec
Reputation Power: 0
|
|
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
|

January 27th, 2012, 01:08 PM
|
|
|
|
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
|

January 27th, 2012, 01:49 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 3
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'
|

January 27th, 2012, 03:19 PM
|
|
Registered User
|
|
Join Date: Jan 2012
Posts: 3
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 
|

January 27th, 2012, 06:28 PM
|
|
|
|
I'm glad you got it solved.
|

February 17th, 2012, 05:10 AM
|
|
Registered User
|
|
Join Date: Dec 2011
Posts: 7
Time spent in forums: 1 h 36 m 3 sec
Reputation Power: 0
|
|
|
Thanks for solving our problem.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|