none
VBA Compile Error RRS feed

  • Question

  • I have created a macro to be able to open an email template I am getting an error when I test run it compile error sub or function not defined. See below there are 9 different templates I am working with. I am new to using VBA and have much to learn.

    Dim template As String
    Sub OpenTemplate1()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email AZ.oft")
    MakeItem
    End Sub

    Sub OpenTemplate2()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email Contractor.oft")
    MakeItem
    End Sub

    Sub OpenTemplate3()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email MA.oft")
    MakeItem
    End Sub

    Sub OpenTemplate4()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email NC.oft")
    MakeItem
    End Sub

    Sub OpenTemplate5()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email NJ.oft")
    MakeItem
    End Sub

    Sub OpenTemplate6()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email NV.oft")
    MakeItem
    End Sub

    Sub OpenTemplate7()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email NY.oft")
    MakeItem
    End Sub

    Sub OpenTemplate8()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email Perm Employee.oft")
    MakeItem
    End Sub

    Sub OpenTemplate9()
     Set msg = Application.CreateItemFromTemplate("C:\Users\ccriasia\AppData\Roaming\Microsoft\Templates\New Hire Email Deltek ID.oft")
    MakeItem
    End Sub


    Monday, May 21, 2018 5:01 PM

All replies

  • Hello Christine,

    I can found that you called a Sub/Function named "MakeItem". It is not a built-in function. Have you ever created it?

    Where is it and What is the content in it?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 22, 2018 1:48 AM