|
|
|||||||
Hi All, I have this VB code that I am trying to convert into Kix, Creates an signature in outlook. It works up to a certain point and then bombs out and I can't understand why (mainly becuause my VB Scripting is crap). This is the line of code, I think, where it is having the problems. $objSignatureEntries.Add "AD Signature", $objSelection The other minor problem I'm having is once the signature is created all of the text is spaced too far apart. I need to be able to do a "Shift Return" instead of a simple "Return" so I don't have such a large space between each line. Does anyone know how to get around this? I've included both the VB and KIX code Any help would be much appreciated. thanks. Code: On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") strUser = objSysInfo.UserName Set objUser = GetObject("LDAP://" & strUser) strName = objUser.FullName strSN = objUser.sn strmobile = objUser.mobile strTitle = objUser.Title strDepartment = objUser.Department strCompany = objUser.Company strPhone = objUser.telephoneNumber strGivenName = objUser.givenname 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.TypeText "Kind Regards," objSelection.TypeParagraph() objSelection.TypeParagraph() objSelection.TypeText strGivenName & " " & strSN objSelection.TypeParagraph() objSelection.TypeText strTitle objSelection.TypeParagraph() objSelection.TypeParagraph() 'objSelection.TypeText strDepartment 'objSelection.TypeParagraph() objSelection.TypeText strCompany objSelection.TypeParagraph() objSelection.TypeText "P: " & strPhone objSelection.TypeParagraph() objSelection.TypeText "M: " & strmobile objSelection.TypeParagraph() objSelection.TypeText strmail Set objSelection = objDoc.Range() [color:#CC0000]objSignatureEntries.Add "AD Signature", objSelection[/color] objSignatureObject.NewMessageSignature = "AD Signature" objSignatureObject.ReplyMessageSignature = "AD Signature" objDoc.Saved = True objWord.Quit Code: $objSysInfo = CreateObject("ADSystemInfo") $strUser = $objSysInfo.UserName $objUser = GetObject("LDAP://" + $strUser) $strName = $objUser.FullName $strSN = $objUser.sn $strmobile = $objUser.mobile $strTitle = $objUser.Title $strDepartment = $objUser.Department $strCompany = $objUser.Company $strPhone = $objUser.telephoneNumber $strGivenName = $objUser.givenname $strMail = $objUser.mail $objWord = CreateObject("Word.Application") $objDoc = $objWord.Documents.Add() $objSelection = $objWord.Selection $objEmailOptions = $objWord.EmailOptions $objSignatureObject = $objEmailOptions.EmailSignature $objSignatureEntries = $objSignatureObject.EmailSignatureEntries $objSelection.TypeText "Kind Regards," $objSelection.TypeParagraph() $objSelection.TypeParagraph() $objSelection.TypeText $strGivenName + " " + $strSN $objSelection.TypeParagraph() $objSelection.TypeText $strTitle $objSelection.TypeParagraph() $objSelection.TypeParagraph() '$objSelection.TypeText strDepartment '$objSelection.TypeParagraph() $objSelection.TypeText $strCompany $objSelection.TypeParagraph() $objSelection.TypeText "P: " + $strPhone $objSelection.TypeParagraph() $objSelection.TypeText "F: 07 3222 9323" $objSelection.TypeParagraph() $objSelection.TypeText "M: " + $strmobile $objSelection.TypeParagraph() $objSelection.TypeText $strmail Set $objSelection = $objDoc.Range() [color:#CC0000]$objSignatureEntries.Add "AD Signature", $objSelection[/color] $objSignatureObject.NewMessageSignature = "AD Signature" $objSignatureObject.ReplyMessageSignature = "AD Signature" $objDoc.Saved = True $objWord.Quit |
||||||||
|
|
|||||||
Try this: Code: $objSysInfo = CreateObject("ADSystemInfo") $strUser = $objSysInfo.UserName $objUser = GetObject("LDAP://" + $strUser) $strName = $objUser.FullName $strSN = $objUser.sn $strmobile = $objUser.mobile $strTitle = $objUser.Title $strDepartment = $objUser.Department $strCompany = $objUser.Company $strPhone = $objUser.telephoneNumber $strGivenName = $objUser.givenname $strMail = $objUser.mail $objWord = CreateObject("Word.Application") $objDoc = $objWord.Documents.Add() $objSelection = $objWord.Selection $objEmailOptions = $objWord.EmailOptions $objSignatureObject = $objEmailOptions.EmailSignature $objSignatureEntries = $objSignatureObject.EmailSignatureEntries $objSelection.TypeText("Kind Regards,") $objSelection.TypeParagraph() $objSelection.TypeParagraph() $objSelection.TypeText($strGivenName + " " + $strSN) $objSelection.TypeParagraph() $objSelection.TypeText($strTitle) $objSelection.TypeParagraph() $objSelection.TypeParagraph() ;objSelection.TypeText($strDepartment) ;objSelection.TypeParagraph() $objSelection.TypeText($strCompany) $objSelection.TypeParagraph() $objSelection.TypeText("P: " + $strPhone) $objSelection.TypeParagraph() $objSelection.TypeText("M: " + $strmobile) $objSelection.TypeParagraph() $objSelection.TypeText($strmail) $objSelection = $objDoc.Range() [color:#CC0000]$objSignatureEntries.Add("AD Signature", $objSelection)[/color] $objSignatureObject.NewMessageSignature = "AD Signature" $objSignatureObject.ReplyMessageSignature = "AD Signature" $objDoc.Saved = 1 $objWord.Quit If it doesn't work try removing the [color] /[color] tags |
||||||||
|
|
|||||||
Hi Apronk, Thanks for the prompt reply. I tried your updated version of the code, however, I get the following error: ERROR : IDispatch pointers not allowed in expressions! Line : 78 Line 78 is: $objSignatureEntries.Add("AD Signature", $objSelection) EDIT: The signature is now being created, it wasn't before. Any other suggestions? BTW, the color tags shouldn't be there. |
||||||||
|
|
|||||||
If line 78 is returning an object, KiXtart will try and display it. As it cannot you will get an error. If you don't want the object then assign it to a junk variable: Code: $DISCARD=$objSignatureEntries.Add("AD Signature", $objSelection) |
||||||||
|
|
|||||||
Hi Howard, It Worked! thanks a million (as always ). Any idea on how to stop the extra spaces between the lines? e.g. Microsoft Office I need to be able to script the Shift+Enter |
||||||||
|
|
|||||||
Who's Howard? Your problem is the TypeParagraph, which is inserting a <P> into the code when you need a <BR>. Wherever you are using TypeParagraph, try sending Chr(11) as typed text instead. |
||||||||
|
|
|||||||
Sorry Richard, I have no idea who howard is, serious case of brain fade. how would I go about sending a Chr(11)? |
||||||||
|
|
|||||||
Just use TypeText. You can catenate it to your text, or keep it on seperate lines. Something like this: Code: $objSysInfo = CreateObject("ADSystemInfo") $strUser = $objSysInfo.UserName $objUser = GetObject("LDAP://" + $strUser) $strName = $objUser.FullName $strSN = $objUser.sn $strmobile = $objUser.mobile $strTitle = $objUser.Title $strDepartment = $objUser.Department $strCompany = $objUser.Company $strPhone = $objUser.telephoneNumber $strGivenName = $objUser.givenname $strMail = $objUser.mail $objWord = CreateObject("Word.Application") $objDoc = $objWord.Documents.Add() $objSelection = $objWord.Selection $objEmailOptions = $objWord.EmailOptions $objSignatureObject = $objEmailOptions.EmailSignature $objSignatureEntries = $objSignatureObject.EmailSignatureEntries $objSelection.TypeText("Kind Regards,") $objSelection.TypeText(Chr(11)) $objSelection.TypeText(Chr(11)) $objSelection.TypeText($strGivenName + " " + $strSN) $objSelection.TypeText(Chr(11)) $objSelection.TypeText($strTitle) $objSelection.TypeText(Chr(11)) $objSelection.TypeText(Chr(11)) ;objSelection.TypeText($strDepartment) ;$objSelection.TypeText(Chr(11)) $objSelection.TypeText($strCompany) $objSelection.TypeText(Chr(11)) $objSelection.TypeText("P: " + $strPhone) $objSelection.TypeText(Chr(11)) $objSelection.TypeText("M: " + $strmobile) $objSelection.TypeText(Chr(11)) $objSelection.TypeText($strmail) $objSelection = $objDoc.Range() $objSignature=$objSignatureEntries.Add("AD Signature", $objSelection) $objSignatureObject.NewMessageSignature = "AD Signature" $objSignatureObject.ReplyMessageSignature = "AD Signature" $objDoc.Saved = 1 $objWord.Quit |
||||||||
|
|
|||||||
It works great, thanks. |
||||||||
|
|
|||||||
Cool, glad Richard could help you out, just got back |
||||||||
|
|
|||||||
Hello everyone, I know the post is very old but I was doing research on creating a maintenance agree in Outlook 2007 and found this post. And I wonder if it would be possible to change the format of the signature of TEXT to HTML? If yes, how would it be? |
||||||||
|
|
|||||||
Have you looked at the Signature Tool in the script vault? Uses both HTM and TXT sigs, supports images, and has no reliance on MS Word. Glenn |
||||||||
|
|
|||||||
I Found another post where I can set font, color, size, but now just need to know how it would be to set an image alongside the text to be something like |....| Name |....| Company where the 2 lines containing "|....|" would a single image |
||||||||
|
|
|||||||
That's precisely what's demonstrated in that post, along with all the code to create the sigs.. The script vault contains mostly ready-to-use code. We have a slightly updated version of the same code with an added management tool that we use at many of out clients - no custom coding, just a custom template for the HTM and TXT formats. |
||||||||
|
|
|||||||
You are sure to put the text next to a picture as examples? If yes, I apologize because I did not understand how it would be possible to do... |
||||||||
|
|
|||||||
In the Signature Tool as it possible to get him to put the html file in Outlook 2007? The problem is exactly this, associate your HTML file as the user's signature in Outlook 2007 ... In Outlook Express worked perfectly, but the company used the 2007 |
||||||||
|
|
|||||||
Hi ! I was working on a similar Signature but I need to create a Table and add data in it. I succed in creating my Table but i dont anderstant how to merge 2 cells together. Here is the original Cells Merge VB usage : Code: Set myTable = ActiveDocument.Tables(1) Set myRange = ActiveDocument.Range(myTable.Cell(1, 1) _ .Range.Start, myTable.Cell(1, 2).Range.End) myRange.Cells.Merge |