Consulting

Results 1 to 8 of 8

Thread: Macro to pull up template email, need to removing signature and change "From"

  1. #1

    Macro to pull up template email, need to removing signature and change "From"

    We have a Group email we send emails out with and I have a VBA code to pull those emails up, but they are always preset with my personal email and my signature. How could I add to the current code to have a different email and remove my signature.
    Very new to VBA. Thanks in advance

    Sub Quickturnaround()
        'Open Quick Turnaround email template
        Set temp = Application.CreateItemFromTemplate( _
        "C:\Users\kyle-p\AppData\Roaming\" _
        & "Microsoft\Templates\Quick Turnaround.oft")
        temp.Display
        Set temp = Nothing
    End Sub

  2. #2
    If the signature is in the template, remove it from the template and when you create a new message using that template the default signature associated with the account used to create it will be appended when you create the message..
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    I have a group email and a personal work email. My signature is only attached to the Personal work email, but I don’t want a signature at all with the group email but it continues to load my personal work email. So when I open up a template email, it loads my signature even thought the template never had one. It also loads it so the "From" is from my personal and not the group email even if template is saved as "Group Email"

  4. #4
    The account used with a template is the account set when the template is created and stored in that template. If your group mail account has a signature associated with it, that signature will be added, however if you want to retain the default signature on your group account and create a message from your template without it, then you need to create the message and remove the signature e.g.

    Sub Quickturnaround()
    Dim oItem As MailItem
    Dim oDoc As Object
    Dim oBm As Object
    Dim oRng As Object
        'Open Quick Turnaround email template
        Set oItem = Application.CreateItemFromTemplate( _
                    "C:\Users\kyle-p\AppData\Roaming\" _
                    & "Microsoft\Templates\Quick Turnaround.oft")
        Set oDoc = oItem.GetInspector.WordEditor
        oItem.Display
        Set oBm = oDoc.Bookmarks("_MailAutoSig")
        If Not oBm Is Nothing Then
            Set oRng = oBm.Range
            oRng.Text = ""
        End If
    lbl_Exit:
        Set oItem = Nothing
        Set oDoc = Nothing
        Set oBm = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5


    These are actually being saved off on our Personal emailaccount templates and not the group account. So if I had a template saved on myaccount when I go to load the template it would load my default “From” and mysignature. The issue is when I go to load that template from my templates, I wantthe “From” to be from the group email and have no signature. I can’t find wherethey save off the Templates for the group email to alter the code the look upthere locations so I’m having to use my personal account rather than the groupaccount when starting.

    Above Code is still giving me my Personal "From" and my signature.



  6. #6
    The From account is saved in the template when the template is saved. It should remain in that template.

    The answer then appears to be to create a blank e-mail from your template, delete the signature, change the from address, then save it as a template with the same name, overwriting original template.

    The macro I posted should delete the default signature added when you create a message, but perhaps not if that signature is saved in the template as then it is part of the message text.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  7. #7
    So here’s how my templates are saved. I pull up a new email,once open I have to go to the Drop down box for “From:” and change it to thegroup email. I then Remove the signature and type in Subject and Body. I savethis as on oft. File. When I go to “Choose Form” and open the Body and Subjectare there, but it has re-added my Signature and reverted the “From:” back tothe personal email rather than the group email. Only thing I can think of is doI need to be an admin or something for the Group email? I’f I go to file itpulls up my personal account but shows nothing about the group account underfile. Heck I don’t even know the password for the group email. I can send pictures if that help


  8. #8
    Does the macro remove the signature if you use it to create the message?
    It should adopt the from address in the message template and certainly does here. However try the following. You will need to insert the display name of your group account.
    This too works here.

    Sub Quickturnaround()
    Dim oItem As MailItem
    Dim oAccount As Account
    Dim oDoc As Object
    Dim oBm As Object
    Dim oRng As Object
    Const strAcc As String = "account displayname" 'change as appropriate
    
        'Open Quick Turnaround email template
        Set oItem = Application.CreateItemFromTemplate( _
                    "C:\Users\kyle-p\AppData\Roaming\" _
                    & "Microsoft\Templates\Quick Turnaround.oft")
        For Each oAccount In Session.Accounts
            If oAccount.DisplayName = strAcc Then
                oItem.SendUsingAccount = oAccount
                Exit For
            End If
        Next
        Set oDoc = oItem.GetInspector.WordEditor
        oItem.Display
        Set oBm = oDoc.Bookmarks("_MailAutoSig")
        If Not oBm Is Nothing Then
            Set oRng = oBm.Range
            oRng.Text = ""
        End If
    lbl_Exit:
        Set oAccount = Nothing
        Set oItem = Nothing
        Set oDoc = Nothing
        Set oBm = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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