PDA

View Full Version : Swapping Templates with a macro



punktilend
09-25-2014, 12:33 PM
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.

gmayor
09-25-2014, 09:33 PM
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

punktilend
09-26-2014, 04:16 AM
Thank you for the help, that worked perfectly! Would you recommend anything online that I could use as a reference to learn more vba?