logan
logan

Reputation: 8346

Display Excel inside VB6 / VB.NET Form & work with Excel without excel menu

I have an Excel sheet with Macros enabled. I want to display the Excel sheet inside a VB6/VB.NET form without excel menu header and perform excel activities inside the form.

Please note that I need to perform some macros actions when some cell is entered...

My Objective is to create a standalone VB6/VB.Net Form in which excel cells should be displayed for performing marco actions.

I have tried searching for any sample but no luck. It should be something like this... enter image description here

Can any one hint me to achieve this ?

Upvotes: 0

Views: 3691

Answers (2)

Jason Bayldon
Jason Bayldon

Reputation: 1296

I did a lot of research into this last year. There is no available package to do what you are asking that is provided by MS or for free, however, you could create a datagridview (DGV) in vb.net and load the data into the DGV via ADO.NET. The data loaded into the cells will mirror your spreadsheet. Then when you modify the cells in the DGV, have a label as you have shown to update the data changes back to the excel sheet.

http://social.msdn.microsoft.com/Forums/en-US/7a1c828d-04ed-4a8d-927d-3649f29d2060/import-data-from-excel-sheet-into-datagridview

As far as calling the macro, use the excel interop feature to call a macro:

http://social.msdn.microsoft.com/Forums/office/en-US/2e33b8e5-c9fd-42a1-8d67-3d61d2cedc1c/how-to-call-excel-macros-programmatically-in-c

There may be some third party support for what you are doing, but of course it costs money: http://www.componentone.com/SuperProducts/SpreadStudio/?gclid=CLKIy6TqwLkCFYZlOgodhToAZg

Upvotes: 0

Christian Sauer
Christian Sauer

Reputation: 10899

As far as I can tell - this is not possible. The reason being that you cannot subclass the excel window in VBA. If you program outside of excel with VB.NET or VB6 it would be sort of possible, but would probably not work really good. If you only want to display some data from a sheet and perform some small actions on them, you could probably read the Data via the EPPLUS Library, display them as a datatable (EPPLUS can convert between datatable and excel files), perform your actions and save them to the file afterwards. But this would only work in VB.net

Upvotes: 2

Related Questions