locked
outlook signature RRS feed

  • Question

  • Dear all,

    We are using the script below to automaticaly add signature to all users in our domain. The script works great,but i need to change the position of the picture to be square with the text. I am not script expert, could someone help me with this please?

    script.Sleep 5000
    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
    strMobile = objUser.mobile
    straddress = objUser.streetaddress
    strfax = objUser.facsimileTelephoneNumber
    strmail = objUser.mail

    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.Style = "No Spacing"
    objSelection.Font.Bold = True
    objSelection.Font.Color=RGB(54,95,143)
    objSelection.Font.Name = "Helvetica"
    objSelection.Font.Size = 11
    objSelection.TypeText strName
    objSelection.TypeParagraph()
    objSelection.Font.Bold = False
    objSelection.Font.Size = 10
    objSelection.TypeText strTitle
    objSelection.Font.Size = 11
    objSelection.TypeParagraph()
    objSelection.TypeParagraph()
    objSelection.Font.Bold = True
    objSelection.TypeText strCompany
    objSelection.TypeParagraph()
    objSelection.Font.Bold = False
    objSelection.Font.Size = 10
    objSelection.TypeText straddress
    objSelection.TypeParagraph()
    objSelection.TypeParagraph()
    objSelection.TypeText "T: +30000000000/" & strPhone & " F:" & strfax
    objSelection.TypeParagraph()
    objSelection.TypeText "Email: " & strmail
    objSelection.TypeParagraph()
    objSelection.TypeText "Web Page: www.xxx.com"
    objSelection.TypeParagraph()

    objSelection.TypeParagraph()

    objSelection.TypeParagraph()
    Set colShapes = objDoc.Shapes
    Set objShape = objSelection.InlineShapes.AddPicture("picture path")
    objShape.Height = 130
    objShape.Width = 410
    objSelection.TypeParagraph()
    objSelection.Font.Name = "webdings"
    objSelection.Font.Size = "20"
    objSelection.Font.Bold = True
    objSelection.Font.Color = RGB(0,153,0)
    objSelection.TypeText "P"
    objSelection.TypeText " "
    objSelection.Font.Bold = True
    objSelection.Font.Color=RGB(0,128,0)
    objSelection.Font.Name = "arial"
    objSelection.Font.Size = 9
    objSelection.TypeText "Please consider the environment before printing"
    objSelection.TypeParagraph()
    objSelection.TypeParagraph()
    objSelection.Font.Color=RGB(169,169,169)
    objSelection.Font.Name = "arial"
    objSelection.Font.Size = 8
    objSelection.TypeText "some text"
    Set objSelection = objDoc.Range()


    objSignatureEntries.Add "AD Signature", objSelection
    objSignatureObject.NewMessageSignature = "AD Signature"
    objSignatureObject.ReplyMessageSignature = "AD Signature"

    objDoc.Saved = True
    objWord.Quit

    • Moved by Bill_Stewart Friday, December 30, 2016 8:44 PM This is not Outlook support forum
    Friday, November 11, 2016 9:35 AM

Answers

  • Hi Pantos,

    I don't have a running test instance of Outlook so can't actually test this. You will need to modify the settings to what you desire.

    Sorry, I didn't copy the whole script from the Scripting Guy Forum. If you modify the numbers at the top, that will move the picture around. There are also, top, bottom, right and left if you need to use them. Below, left is being used.

    Const wdShapeCenter = -999995 Const wdWrapSquare = 0

    Set objShape = objDoc.Shapes objShape.AddPicture(“C:\Scripts\Welder-small.jpg”) Set objShapeRange = objDoc.Shapes.Range(1) objShapeRange.Left = wdShapeCenter objShapeRange.WrapFormat.Type = wdWrapSquare

    Hope this helps.
    Thanks, Tim. | Please remember to mark the replies as answers if they help. |


    • Edited by Tim Haintz Friday, November 11, 2016 8:12 PM
    • Marked as answer by pantoskom Sunday, April 19, 2020 2:16 PM
    Friday, November 11, 2016 8:12 PM

All replies

  • Looks like you need an object range parameter. 

    From here: https://blogs.technet.microsoft.com/heyscriptingguy/2006/10/26/how-can-i-center-align-a-picture-in-a-word-document/

    Set objShape = objDoc.Shapes
    objShape.AddPicture(“C:\Scripts\Welder-small.jpg”)
    Set objShapeRange = objDoc.Shapes.Range(1)
    objShapeRange.Left = wdShapeCenter
    objShapeRange.WrapFormat.Type = wdWrapSquare

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshapes.addpicture.aspx has further details.

    You will need to adjust these parameters to suit your requirements.


    Thanks, Tim. | Please remember to mark the replies as answers if they help. |


    • Edited by Tim Haintz Friday, November 11, 2016 10:30 AM
    Friday, November 11, 2016 10:29 AM
  • Hi tim,

    Ok i tried this and it puts the picture botom left, i want the picture to be inline wth the text and left. how can i do this?

    thanks

    pantos

    Friday, November 11, 2016 12:35 PM
  • Hi Pantos,

    I don't have a running test instance of Outlook so can't actually test this. You will need to modify the settings to what you desire.

    Sorry, I didn't copy the whole script from the Scripting Guy Forum. If you modify the numbers at the top, that will move the picture around. There are also, top, bottom, right and left if you need to use them. Below, left is being used.

    Const wdShapeCenter = -999995 Const wdWrapSquare = 0

    Set objShape = objDoc.Shapes objShape.AddPicture(“C:\Scripts\Welder-small.jpg”) Set objShapeRange = objDoc.Shapes.Range(1) objShapeRange.Left = wdShapeCenter objShapeRange.WrapFormat.Type = wdWrapSquare

    Hope this helps.
    Thanks, Tim. | Please remember to mark the replies as answers if they help. |


    • Edited by Tim Haintz Friday, November 11, 2016 8:12 PM
    • Marked as answer by pantoskom Sunday, April 19, 2020 2:16 PM
    Friday, November 11, 2016 8:12 PM
  • The easiest way to build a signature is to create a template then open and populate its fields and save.  This way you can easily visually change the look and rerun the simple script.


    \_(ツ)_/

    Friday, November 11, 2016 8:23 PM