This macro keeps giving me a run-time error '5'.
I'm assuming that it isn't possible to set an object equal to something inside an if statement. Is this true? And is there any way around this problem?
Code:
Dim myOlApp As Object
Dim MyItem As Object
Set myOlApp = CreateObject("Outlook.Application")
If Range("C6").Value = "June" Then
MyItem = myOlApp.CreateItemFromTemplate(JuneTemplate) 'THE ERROR HIGHLIGHTS THIS LINE
ElseIf Range("C6").Value = "July" Then
MyItem = myOlApp.CreateItemFromTemplate(JulyTemplate)
End If