Sending commands from an excel file to a C # program

I have a program that reads data from Excel and writes data to an Excel file. I need to send commands from an Excel file to a C # program (for example, grab F9 from excel and get it in a C # program)

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

How can i do this? >

+4
source share
3 answers

the excel application interface also provides events for some excel functions, for example.

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; 
+1
source

You may have to call your own Win32 methods to add a message hook that looks for a character message in the Excel window.

0
source

oferyo,

Hello. You do not indicate how much data you need to deal with? Either type, or (questions such as: “material” sent to the target Excel file, contains graphs or just data?).

You have not mentioned which version of C # you are using, but can you think of calling a web service from a VBA script embedded or added to the original Excel spreadsheet?

MSDN article on calling WebServices from VBA

I can't remember how to drop VBA code to specific events in an Excel spreadsheet (e.g. recount / press F9), but I think it should be trivial.

If you are using C # 3.5 or later, you can host the WCF service in the application ... but I would suggest a more detailed description of the question, because it could be the solution VBA-> WCF / WebService-> Application -engineered?

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

Yours faithfully,

Aidanapword

0
source

Source: https://habr.com/ru/post/1346580/


All Articles