Communicating between C# and VBA

前端 未结 3 1462
长发绾君心
长发绾君心 2021-01-05 02:12

At the request of my boss I created a small set of scripts that are used to periodically monitor the status of certain devices and processes. This info is subsequently proce

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-05 03:14

    I believe the code in this link does roughly what you want:

    • C# code creates a COM object (in the example it is IE, but from your description, you have already managed to create an instance of your VBA routine)

    • It attaches a .Net event handler (using +=) to an event raised by the COM object (when the title changes)

    • It defines sample event handling code

    http://msdn.microsoft.com/en-us/library/66ahbe6y.aspx

    I don't profess to understand this code, my objective is to show convoluted this solution would be! You should really build this in just one solution. A total VBA will solution will be quicker to develop (you only need to learn VBA forms which is easy), but old technology. A total C# solution will be slower to develop but then you will get to learn C#.

    Performance actually is an issue. If it performs inefficiently now, what happens when you have 5x as many records to process? You should solve the performance issue before you get that many records.

提交回复
热议问题