Results 1 to 4 of 4

Thread: Insert Signature into Outlook 2K

  1. #1

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Insert Signature into Outlook 2K

    Something like so...
    VB Code:
    1. Private Sub InsertSig(strSigName As String)
    2.  
    3.     Dim objItem As Object
    4.     Dim objInsp As Outlook.Inspector
    5.     'requires a project reference to the Microsoft Word library
    6.     Dim objDoc As Word.Document
    7.     Dim objSel As Word.Selection
    8.     'requires a project reference to the Microsoft Office library
    9.     Dim objCB As Office.CommandBar
    10.     Dim objCBP As Office.CommandBarPopup
    11.     Dim objCBB As Office.CommandBarButton
    12.     Dim colCBControls As Office.CommandBarControls
    13.    
    14.     On Error Resume Next
    15.  
    16.     Set objInsp = Application.ActiveInspector
    17.     If Not objInsp Is Nothing Then
    18.         Set objItem = objInsp.CurrentItem
    19.         If objItem.Class = olMail Then ' editor is WordMail
    20.             If objInsp.EditorType = olEditorWord Then
    21.                 ' next statement will trigger security prompt
    22.                 ' in Outlook 2002 SP3
    23.                 Set objDoc = objInsp.WordEditor
    24.                 Set objSel = objDoc.Application.Selection
    25.                 If objDoc.Bookmarks("_MailAutoSig") Is Nothing Then
    26.                     objDoc.Bookmarks.Add Range:=objSel.Range, Name:="_MailAutoSig"
    27.                 End If
    28.                 objSel.GoTo What:=wdGoToBookmark, Name:="_MailAutoSig"
    29.                 Set objCB = objDoc.CommandBars("AutoSignature Popup")
    30.                 If Not objCB Is Nothing Then
    31.                     Set colCBControls = objCB.Controls
    32.                 End If
    33.             Else ' editor is not WordMail
    34.                 ' get the Insert | Signature submenu
    35.                 Set objCBP = Application.ActiveInspector.CommandBars.FindControl(, 31145)
    36.                 If Not objCBP Is Nothing Then
    37.                     Set colCBControls = objCBP.Controls
    38.                 End If
    39.             End If
    40.         End If
    41.         If Not colCBControls Is Nothing Then
    42.             For Each objCBB In colCBControls
    43.                 If objCBB.Caption = strSigName Then
    44.                     objCBB.Execute
    45.                     Exit For
    46.                 End If
    47.             Next
    48.         End If
    49.     End If
    50.  
    51.     Set objInsp = Nothing
    52.     Set objItem = Nothing
    53.     Set objDoc = Nothing
    54.     Set objSel = Nothing
    55.     Set objCB = Nothing
    56.     Set objCBB = Nothing
    57. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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
  •  



Click Here to Expand Forum to Full Width