none
Difference between Excel "Application.Run" and "Application._Run2" - A concept RRS feed

  • Question

  • Hi,

    Can someone please add to my knowledge regarding "Excel Application._Run2(...)" method? Microsoft documentation for office does not tell you much - just describes as "reserved for internal use". Please refer to the following link:
    https://msdn.microsoft.com/en-us/library/ms261734(v=office.15).aspx

    I was earlier using Excel "Application.ExecuteExcel4Macro(...)" in my .Net COM Add-In in order to pass the name of a macro defined in my Excel macro-enabled add-in (*.xlam) written in VBA (of course), which in turn calls a custom C++ API. I am calling that macro when a user clicks on one of the relevant menu items.

    Let me illustrate a scenario. I opened two workbooks and I call that macro (from .Net COM Add-In) using "Application.ExecuteExcel4Macro(...)" function. The function does what it does, but when I switch to other workbook then, Excel becomes unresponsive to user clicks. However, calling that macro using "Application.Run(...)" fixes the problem, but this leads to another problem of executing a macro, repeatedly (that is it executes twice as if it is in a loop, from some reason). When I call a macro using "Application._Run2(...)", this fixes the problem altogether.

    From the above summary, I wanted to know the difference between "Application.Run(...)" and "Appication._Run2(...)". I would be very thankful.

    Kind regards,
    Misbah

    Thursday, April 14, 2016 12:09 PM

All replies

  • Hi, Misbah

    Please visit the link below for getting the information regarding Application.Run

    Application.Run Method (Excel)

    and for getting the information regarding Application.Run as you already know a link

    _Application._Run2 method

    Application.Run Method

    Runs a macro or calls a function. This can be used to run a macro written in Visual Basic or the Microsoft Excel macro language, or to run a function in a DLL or XLL.

    _Application._Run2 method

    Reserved for internal use.

    Syntax for Application.Run Method

    expression .Run(Macro, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30)

    Syntax for _Application._Run2 method

    Object _Run2(
    	Object Macro,Object Arg1,Object Arg2,Object Arg3,Object Arg4,Object Arg5,Object Arg6,Object Arg7,Object Arg8,Object Arg9,Object Arg10,Object Arg11,Object Arg12,Object Arg13,Object Arg14,Object Arg15,Object Arg16,Object Arg17,Object Arg18,Object Arg19,Object Arg20,Object Arg21,Object Arg22,Object Arg23,Object Arg24,Object Arg25,Object Arg26,Object Arg27,Object Arg28,Object Arg29,Object Arg30)
    

    Application.Run Method

    You cannot use named arguments with this method. Arguments must be passed by position.

    The Run method returns whatever the called macro returns. Objects passed as arguments to the macro are converted to values (by applying the Value property to the object). This means that you cannot pass objects to macros by using the Run method.

    Regards

    Deepak

    Friday, April 15, 2016 5:03 AM
    Moderator
  • Hi Deepak,

    Thank you very much for your reply and for the information. However, my question is still unanswered. I have already gone through the documentation that you have referred. In fact, I am already referring to the same link regarding "_Application._Run2" in my question, that you have mentioned.

    All I asked of the reason as to why the "Application.Run" and "Application.ExecuteExcel4Macro" functions did not work and only the "Application._Run2" worked in Excel 2013, as expected.

    Please go through my question again in which I have explained the scenario.

    Friday, April 15, 2016 2:51 PM
  • Hi,

    Has anyone got any suggestions regarding my query, to add to my knowledge? I have been searching on the Internet and I could not find the answer to my question.

    Kind regards,

    Misbah

    Tuesday, April 19, 2016 8:43 AM
  • Hi Misbah Masood-ul-Hasan,

    The information I find regarding your issue that I had already provided to you. I also try to find further but unfortunately I did find any useful information. if I will find something useful I will provide you

    Regards

    Deepak


    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.

    Tuesday, April 19, 2016 8:53 AM
    Moderator