Consulting

Results 1 to 3 of 3

Thread: Swapping Templates with a macro

  1. #1

    Swapping Templates with a macro

    Hi,

    I have a template that I use to email BakerBob. I have turned into a macro button in Outlook 2010.

    Sub BakerBob()
    Set msg = Application.CreateItemFromTemplate("C:\Users\punktilend\AppData\Roaming\Microsoft\Templates\BakerBob.oft")
    msg.Display
    End Sub
    What I would like to do is have 2 templates (BakerBob_morning.oft & BakerBob_evening.oft) and when I use that button it will know what time it is and if it is before 12noonest use the morning template but use afternoon if after 12noonest.

    Do I use a boolean and if so how would I input that?

    Thank you in advance.

  2. #2
    You could use

    Dim strTime As String
        strTime = Format(Time, "am/pm")
        If strTime = "am" Then
            'it's morning
        Else
            'it's afternoon
        End If
    to determine which template to use
    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
    Thank you for the help, that worked perfectly! Would you recommend anything online that I could use as a reference to learn more vba?

Tags for this Thread

Posting Permissions

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