none
How can I interrupt VBA routines via C# Interop Automation? RRS feed

  • Question

  • Good Day,

    I have a program that automates excel quite extensively via C# interop automation. 

    A feature I must build requires that I run a VBA method if it exists in the workbook that part is working fine, however I would like to put a time limit on how long the VBA routine is aloud to run so that I can cleanly cancel the VBA and return control to the main application.

    Any assistance anyone may have would be greatly appreciated.

    Saturday, September 14, 2019 8:42 PM

All replies

  • Hi Scott Gall, 

    Thank you for posting here.

    According to your description, I have found a reference:

    C# Calling VBA

    Hope it can help you.

    Besides, if you have more problems about excel, I suggest that you can post your question in Excel for Developers forums for more help.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,

    Xingyu Zhao


    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, September 17, 2019 8:24 AM
    Moderator
  • Thank you,

    This link is helpful in explaining how one could make the linkage/call to VBA, however it does not provide any guidance as far as how one may interrupt or manage that call after it has been sent.

    That is the key part I am looking for guidance with. Any support / suggestions would be greatly appreciated.


    Tuesday, September 17, 2019 11:38 AM
  • Hi Scott Gall, 

    Thanks for your feedback.

    I find that you may need to set something in VBA to interrupt it, so I suggest you ask the question in VBA forums for more help.

    Besides, I find a reference, and I hope it is helpful to your question.

    interrupting a C# method that was called from VBA

    Best Regards,

    Xingyu Zhao


    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.

    Thursday, September 19, 2019 9:47 AM
    Moderator