Click here to Skip to main content
15,877,967 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Wanting to use a For Next variable in “xxxx.Rows.Count” Pin
Member 834559924-May-17 6:33
Member 834559924-May-17 6:33 
QuestionCreating Access 2007+ files Pin
JR21222-May-17 18:47
JR21222-May-17 18:47 
AnswerRe: Creating Access 2007+ files PinPopular
Richard MacCutchan22-May-17 21:54
mveRichard MacCutchan22-May-17 21:54 
GeneralRe: Creating Access 2007+ files Pin
JR21224-May-17 1:38
JR21224-May-17 1:38 
AnswerRe: Creating Access 2007+ files Pin
Maciej Los23-May-17 20:25
mveMaciej Los23-May-17 20:25 
QuestionYahoo Finance API Throwing 504 Status? Pin
Member 1321215119-May-17 22:57
Member 1321215119-May-17 22:57 
AnswerRe: Yahoo Finance API Throwing 504 Status? Pin
Afzaal Ahmad Zeeshan19-May-17 23:56
professionalAfzaal Ahmad Zeeshan19-May-17 23:56 
QuestionOutlook signature code suddenly causing "remote procedure call failed" message Pin
Member 1320910118-May-17 7:18
Member 1320910118-May-17 7:18 
So admittedly I didn't write this code. I found it online and adjusted as I needed. We have been using this code to automatically create signatures and I have it running in several locations. Recently it has been failing to run on workstations in our office. They are all Windows 10 Pro, running office 2016 standard. The script runs fine on our terminal server which is server 2012 r2 with office 2016 standard.

Code fails seemingly at any line which contains objSelection.InlineShapes.AddPicture

If I comment out the first line containing that (line 124) the error happens on the next line containing it. Not sure if there was an update that broke this. Thanks for any help.

VB
' 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 = "default"
strLogoPath = "\\sersbs11\Common Shared Files\EMAILSIGS\seremailgraphic.jpg"
strGiven = objuser.givenName
strSurname = objuser.sn
strAddress1 = "6010 99 Street NW "
strAddress1EXT = objUser.postofficebox
strAddress2 = " Edmonton, AB "
strAddress3 = objuser.st
strPostcode = " T6E-3P2"
strExt = objuser.homephone
strTitle = objUser.title
strEmail =objuser.mail
strCompany = objUser.Company
strPhone = objUser.telephoneNumber
strFax = objUser.facsimileTelephoneNumber
strMobile = objuser.mobile

REM strWeb = objuser.wWWHomePage
REM strNotes = objuser.info
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 one row and two cells
objselection.TypeText Chr(11)
  
Const Number_of_rows = 4
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)

'### Sets up the first cell with the logo inside
Set objCell = objTable.Cell(1, 1)
Set objCellRange = objCell.Range
objSelection.Range = objCell.Range





'### Set up the formatting for the name and title
objSelection.Font.Name = "Arial"
objSelection.Font.Size = 11
objSelection.Font.Bold = True
objSelection.Font.Color = RGB (0,127,127)

'### Type the name and title
objSelection.TypeText     strGiven & " " & strSurname
objSelection.Font.Size = 8
Rem objSelection.Font.Bold = False
objSelection.TypeText strDepartment & Chr(11)


objSelection.Font.Name = "Arial"
objSelection.Font.Size = 9
objSelection.Font.Bold = True
objSelection.Font.Color = RGB (121,121,121)


objSelection.TypeText strTitle & Chr(11)



objSelection.Font.Name = "Arial"
objSelection.Font.Size = 9
objSelection.Font.Bold = False
objSelection.Font.Color = RGB (121,121,121)

if len(strPhone) > 5 and len(strMobile) > 5 then
objSelection.TypeText strEmail & Chr(11) & "P. " & strPhone & Chr(11) & "M. " & strMobile

else if len(strPhone) >5 then
objSelection.TypeText strEmail & Chr(11) & "P. " & strPhone
else if len(strMobile) >5 then
objSelection.TypeText strEmail & Chr(11) & "M. " & strMobile
else
objSelection.TypeText strEmail


end if
end if
end if

Set objCell = objTable.Cell(2, 1)
Set objCellRange = objCell.Range
objCell.Select

'### Set up the formatting for the name and title

objSelection.InlineShapes.AddPicture(strLogoPath)
objSelection.Font.Name = "Arial"
objSelection.Font.Size = 9
objSelection.Font.Bold = False
objSelection.Font.Color = RGB (0,127,127)

if len(strext) = 3 then



    objSelection.TypeText  Chr(11) & strAddress1 & Chr(149) & strAddress2 & Chr(149) & strPostcode  & " " & Chr(149) & " " &_
                            "P. 780.435.2211 Ext: " & strext & " " & Chr(149) & " F. 780.437.4964 " 
                            

else

objSelection.TypeText  Chr(11) & strAddress1 & Chr(149) & strAddress2 & Chr(149) & strPostcode & " " & Chr(149) & " " &_
                            "P. 780.435.2211 " & Chr(149) & " F. 780.437.4964 " 
                            

end if


Set objCell = objTable.Cell(3, 1)
Set objCellRange = objCell.Range
objCell.Select


PicFile0 = "\\sersbs11\Common Shared Files\EMAILSIGS\space.png"
PicFile1 = "\\sersbs11\Common Shared Files\EMAILSIGS\facebook.png"
LinkFile1 = "http://www.facebook.com/specialeventrentals"
PicFile2 = "\\sersbs11\Common Shared Files\EMAILSIGS\twitter.png"
LinkFile2 = "http://www.twitter.com/seredmonton"
PicFile3 = "\\sersbs11\Common Shared Files\EMAILSIGS\wordpress.png"
LinkFile3 = "http://blog.specialeventrentals.com"

PicFile4 = "\\sersbs11\Common Shared Files\EMAILSIGS\youtube.png"
LinkFile4 = "http://www.youtube.com/user/specialeventrentals"

PicFile5 = "\\sersbs11\Common Shared Files\EMAILSIGS\www.png"
LinkFile5 = "http://edmonton.specialeventrentals.com"

PicFile6 = "\\sersbs11\Common Shared Files\EMAILSIGS\pinterest.png"
LinkFile6 = "http://www.pinterest.com/seredmonton/boards/"

PicFile7 = "\\sersbs11\Common Shared Files\EMAILSIGS\linkedin.png"
LinkFile7 = "http://www.linkedin.com/company/special-event-rentals"

PicFile99 = "\\sersbs11\Common Shared Files\EMAILSIGS\seropenhouse.jpg"



REM ObjDoc.Hyperlinks.Add ObjSelection.Range, "http://edmonton.specialeventrentals.com",,,"http://edmonton.specialeventrentals.com" 

REM objSelection.InlineShapes.AddPicture(PicFile0)

Set objShape7 = objSelection.InlineShapes.AddPicture(PicFile5, True)
objDoc.Hyperlinks.Add objShape7.Range, LinkFile5


Set objShape1 = objSelection.InlineShapes.AddPicture(PicFile1, True)
objDoc.Hyperlinks.Add objShape1.Range, LinkFile1

Set objShape2 = objSelection.InlineShapes.AddPicture(PicFile2, True)
objDoc.Hyperlinks.Add objShape2.Range, LinkFile2 & Chr(11)

Set objShape3 = objSelection.InlineShapes.AddPicture(PicFile3, True)
objDoc.Hyperlinks.Add objShape3.Range, LinkFile3 & Chr(11)

Set objShape4 = objSelection.InlineShapes.AddPicture(PicFile4, True)
objDoc.Hyperlinks.Add objShape4.Range, LinkFile4 & Chr(11)

Set objShape5 = objSelection.InlineShapes.AddPicture(PicFile6, True)
objDoc.Hyperlinks.Add objShape5.Range, LinkFile6 & Chr(11)

Set objShape6 = objSelection.InlineShapes.AddPicture(PicFile7, True)
objDoc.Hyperlinks.Add objShape6.Range, LinkFile7 & Chr(11)


Set objCell = objTable.Cell(4, 1)
Set objCellRange = objCell.Range
objCell.Select
objSelection.InlineShapes.AddPicture(PicFile99)



'### 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 = strSignatureName

'### save the signature
objDoc.Saved = True

objWord.Quit

AnswerRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan18-May-17 21:43
mveRichard MacCutchan18-May-17 21:43 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Member 134178014-Dec-19 3:07
Member 134178014-Dec-19 3:07 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan4-Dec-19 3:28
mveRichard MacCutchan4-Dec-19 3:28 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Member 134178014-Dec-19 3:32
Member 134178014-Dec-19 3:32 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan4-Dec-19 3:45
mveRichard MacCutchan4-Dec-19 3:45 
QuestionRetrieving value from an XML file Pin
Ben Senior17-May-17 8:32
Ben Senior17-May-17 8:32 
GeneralRe: Retrieving value from an XML file Pin
PIEBALDconsult17-May-17 14:11
mvePIEBALDconsult17-May-17 14:11 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior17-May-17 22:33
Ben Senior17-May-17 22:33 
GeneralRe: Retrieving value from an XML file Pin
Richard MacCutchan17-May-17 23:08
mveRichard MacCutchan17-May-17 23:08 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior19-May-17 7:40
Ben Senior19-May-17 7:40 
GeneralRe: Retrieving value from an XML file Pin
Richard MacCutchan19-May-17 21:13
mveRichard MacCutchan19-May-17 21:13 
AnswerRe: Retrieving value from an XML file Pin
David Mujica19-May-17 7:02
David Mujica19-May-17 7:02 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior19-May-17 7:26
Ben Senior19-May-17 7:26 
GeneralRe: Retrieving value from an XML file Pin
David Mujica19-May-17 8:28
David Mujica19-May-17 8:28 
AnswerRe: Retrieving value from an XML file Pin
Ben Senior20-May-17 4:28
Ben Senior20-May-17 4:28 
AnswerRe: Retrieving value from an XML file Pin
Meshack Musundi23-May-17 5:58
professionalMeshack Musundi23-May-17 5:58 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior23-May-17 7:33
Ben Senior23-May-17 7:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.