开发者

Is it possible to hit a WinForms "Button" from an Excel spreadsheet (VBA)?

开发者 https://www.devze.com 2023-01-06 09:33 出处:网络
The traders are lazy and they don\'t want to switch applications to hit buttons.When they hit the button in Excel, it sh开发者_StackOverflow社区ould be the same as hitting another button in my WinForm

The traders are lazy and they don't want to switch applications to hit buttons. When they hit the button in Excel, it sh开发者_StackOverflow社区ould be the same as hitting another button in my WinForms app (which pops up a dialog box). Doable?


Yes.

You need to put your functionality into a [ComVisible(true)] DLL and add a reference to it in VBA.

Alternatively, you can write an Excel addin in C#.


  1. Write a COM server that communicates with the WinForms app using the inter-process communication mechanism of your choice
  2. Add an Excel button to the sheet
  3. Write some VBA to call the COM server

It would be nice to expose a COM object directly from the WinForms app in such a way that you can call it through the VBA GetObject function. However, I can't see an obvious way to expose an object to the COM running object table from .NET.

0

精彩评论

暂无评论...
验证码 换一张
取 消