|
-
Apr 29th, 2005, 09:10 AM
#1
Insert Signature into Outlook 2K
How do I insert a signature into a blank email through VBA?
(Preferably not having to 'Build' it)
Thanks!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 29th, 2005, 04:50 PM
#2
Re: Insert Signature into Outlook 2K
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 1st, 2005, 08:30 PM
#3
Re: Insert Signature into Outlook 2K
ok..I will try it out! Thanks again!!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
May 1st, 2005, 08:48 PM
#4
Re: Insert Signature into Outlook 2K
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|