How do I insert a signature into a blank email through VBA?
(Preferably not having to 'Build' it)
Thanks!
Printable View
How do I insert a signature into a blank email through VBA?
(Preferably not having to 'Build' it)
Thanks!
Something like so...
VB Code:
Private Sub InsertSig(strSigName As String) Dim objItem As Object Dim objInsp As Outlook.Inspector 'requires a project reference to the Microsoft Word library Dim objDoc As Word.Document Dim objSel As Word.Selection 'requires a project reference to the Microsoft Office library Dim objCB As Office.CommandBar Dim objCBP As Office.CommandBarPopup Dim objCBB As Office.CommandBarButton Dim colCBControls As Office.CommandBarControls On Error Resume Next Set objInsp = Application.ActiveInspector If Not objInsp Is Nothing Then Set objItem = objInsp.CurrentItem If objItem.Class = olMail Then ' editor is WordMail If objInsp.EditorType = olEditorWord Then ' next statement will trigger security prompt ' in Outlook 2002 SP3 Set objDoc = objInsp.WordEditor Set objSel = objDoc.Application.Selection If objDoc.Bookmarks("_MailAutoSig") Is Nothing Then objDoc.Bookmarks.Add Range:=objSel.Range, Name:="_MailAutoSig" End If objSel.GoTo What:=wdGoToBookmark, Name:="_MailAutoSig" Set objCB = objDoc.CommandBars("AutoSignature Popup") If Not objCB Is Nothing Then Set colCBControls = objCB.Controls End If Else ' editor is not WordMail ' get the Insert | Signature submenu Set objCBP = Application.ActiveInspector.CommandBars.FindControl(, 31145) If Not objCBP Is Nothing Then Set colCBControls = objCBP.Controls End If End If End If If Not colCBControls Is Nothing Then For Each objCBB In colCBControls If objCBB.Caption = strSigName Then objCBB.Execute Exit For End If Next End If End If Set objInsp = Nothing Set objItem = Nothing Set objDoc = Nothing Set objSel = Nothing Set objCB = Nothing Set objCBB = Nothing End Sub
ok..I will try it out! Thanks again!!
If your users dont have Word installed or you dont want to give that added functionality, then you can take it out.
It kind of complicates things. ;)
Ps, I was wondering if you were awake. :D