Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2015
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Copy to Outlook and insert signature?

    I have a Macro, where I am trying to copy an entire document to outlook, and then it brings up the signature at the end, however, it seems to only want to do one or the other...will copy the document and not bring up the signature (if I leave the sig part out), or it fails the copy and only brings up the sig (if I leave that part in).

    IS there a way it can be resolved?

    Code:
    Sub Send_Email()Dim oOutlookApp As Outlook.Application
    Dim oItem As Outlook.MailItem
    On Error Resume Next
    'Start Outlook if it isn't running
    Set oOutlookApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
        Set oOutlookApp = CreateObject("Outlook.Application")
    End If
    'Create a new message
    Set oItem = oOutlookApp.CreateItem(olMailItem)
    'Copy the open document
    Selection.WholeStory
    Selection.Copy
    Selection.End = True
    'Set the WordEditor
    Dim objInsp As Outlook.Inspector
    Dim wdEditor As Word.Document
    Set objInsp = oItem.GetInspector
    Set wdEditor = objInsp.WordEditor
    Dim i As Integer
    'Display the message
    oItem.Display
    wdEditor.Range.Paste
    'Clean up
    Set oItem = Nothing
    Set oOutlookApp = Nothing
    Set objInsp = Nothing
    Set wdEditor = Nothing
    End Sub
    The sig section of the code has been removed as it was frustrating me beyond belief. However it was a few send key commands.

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    The signature should already be in the mail item if it is part of your stationary. If the signature is indeed visible after the line
    oItem.Display

    then all you need to do is paste into the start of the email rather than paste over the entire email contents. This means you only need to change the paste line to...
    wdEditor.Range(0, 0).Paste
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Jan 2015
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you, this has solved the issue! I don't know how I could have been so blind to the obvious!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •