开发者

sending commands from excel file to a c# program

I have a program that reads Data from Excel and write data to Excel file. I need to send commands from the Excel file to the c# program (e.g. capture the F9 from the excel and 开发者_运维问答get it on the c# program)

I am using Microsoft.Office.Interop.Excel framework.

How can i do it?>


the excel application interface also provides events to some excel functions, e.g.

Microsoft.Office.Interop.Excel.Application:

    //
    // Summary:
    //     Occurs after any worksheet is recalculated or after any changed data is plotted
    //     on a chart.
    event AppEvents_SheetCalculateEventHandler SheetCalculate;


You will probably have to call native Win32 methods to add a message hook looking for a character message in the Excel window.


oferyo,

Hello. You don't mention what sorts of volume of data you need to deal with? Or the type, either (questions like: does the stuff 'sent' to the destination Excel file includes graphs or just data?).

You don't mention which version of C# you are using but you could consider calling a web service from the VBA script embedded in or added to the originating Excel spreadsheet?

MSDN article on calling WebServices from within VBA

I can't recall how to plumb VBA code into specific events on the Excel spreadsheet (like the recalculate/press of F9) but I think that should be trivial.

If you are using C# 3.5 or later you can host a WCF service within the application ... but I would suggest describing the question better because it may be the VBA->WCF/WebService->Application solution might be seriously over-engineered?

Hope this helps you think about the options you have within VBA ...

regards,

Aidanapword

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜