none
Outlook Ribbon 2010 - how to run macros RRS feed

Answers

  • Hello Nihar,

    You can use the late binding technology to call a macro from an add-in, for example:

    string[] arFunctionParameters =
                { 
                    sTo,
                    sCC,
                    sBCC,
                    sSubject,
                    sBody
                };
    
    // Run the macro
    outApp.GetType().InvokeMember("MyVBAMacroSub",
                System.Reflection.BindingFlags.Default |
                System.Reflection.BindingFlags.InvokeMethod,
                null, outApp, arFunctionParameters);

    You can read more about that in the HOW TO: Run Office Macros by Using Automation from Visual C# .NET article.

    Saturday, February 28, 2015 7:30 AM
  • Hi Nihar,

    >> I also don't want the ribbon to appear on email read or new email windows.<<

    We use GetCustomUI return the ribbon XML for the different ribbon types. If we only want custom the ribbon for the Explorer ribbon, here is the code for your reference:

            public string GetCustomUI(string ribbonID)
            {
                switch (ribbonID)
                {
                    case "Microsoft.Outlook.Explorer":
                        return GetResourceText("OutlookAddIn1.Ribbon.xml");
                    default:
                        return string.Empty;
                }
    
               // return GetResourceText("OutlookAddIn1.Ribbon.xml");
            }

    You can get more detail about Outlook UI custmization from link below:
    Extending the User Interface in Outlook 2010

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 2, 2015 8:14 AM
    Moderator

All replies

  • Hello Nihar,

    You can use the late binding technology to call a macro from an add-in, for example:

    string[] arFunctionParameters =
                { 
                    sTo,
                    sCC,
                    sBCC,
                    sSubject,
                    sBody
                };
    
    // Run the macro
    outApp.GetType().InvokeMember("MyVBAMacroSub",
                System.Reflection.BindingFlags.Default |
                System.Reflection.BindingFlags.InvokeMethod,
                null, outApp, arFunctionParameters);

    You can read more about that in the HOW TO: Run Office Macros by Using Automation from Visual C# .NET article.

    Saturday, February 28, 2015 7:30 AM
  • Hi Nihar,

    >> I also don't want the ribbon to appear on email read or new email windows.<<

    We use GetCustomUI return the ribbon XML for the different ribbon types. If we only want custom the ribbon for the Explorer ribbon, here is the code for your reference:

            public string GetCustomUI(string ribbonID)
            {
                switch (ribbonID)
                {
                    case "Microsoft.Outlook.Explorer":
                        return GetResourceText("OutlookAddIn1.Ribbon.xml");
                    default:
                        return string.Empty;
                }
    
               // return GetResourceText("OutlookAddIn1.Ribbon.xml");
            }

    You can get more detail about Outlook UI custmization from link below:
    Extending the User Interface in Outlook 2010

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 2, 2015 8:14 AM
    Moderator