E
EagleOne
XL 2003, 2007 and VB.NET 2008 Visual Basic
The myDLL contains the following code options. That said, I am not sure which is correct for my
specific application.
1) Assume that I Excel and a workbook is myWB is open.
2) I wish to run a Sub routing compiled in myDLL. (As if I decided to run a macro on my ActiveSheet)
3) Therefore, in VBA, I'll call myDLL
4) Within myDLL's code, I am not sure what combination of below code lines to use
*********************************************************
Dim xlsApp As Microsoft.Office.Interop.Excel.Application
Dim xlsWB As Microsoft.Office.Interop.Excel.Workbook
Dim xlsSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim xlsCell As Microsoft.Office.Interop.Excel.Range
xlsApp = New Microsoft.Office.Interop.Excel.Application
(How can I stay in the current instance of Excel? "NEW" means that I will not?)
xlsWB = xlsApp.ActiveSheet
'xlsWB = xlsApp.Workbooks.Open("c:\myWB.xls")
xlsSheet = xlsWB.Worksheets(1)
The code above "works" in VB.NET Visual Basic but I'll be in a NEW instance of Excel. Yes/No?
TIA for any thoughts. EagleOne
The myDLL contains the following code options. That said, I am not sure which is correct for my
specific application.
1) Assume that I Excel and a workbook is myWB is open.
2) I wish to run a Sub routing compiled in myDLL. (As if I decided to run a macro on my ActiveSheet)
3) Therefore, in VBA, I'll call myDLL
4) Within myDLL's code, I am not sure what combination of below code lines to use
*********************************************************
Dim xlsApp As Microsoft.Office.Interop.Excel.Application
Dim xlsWB As Microsoft.Office.Interop.Excel.Workbook
Dim xlsSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim xlsCell As Microsoft.Office.Interop.Excel.Range
xlsApp = New Microsoft.Office.Interop.Excel.Application
(How can I stay in the current instance of Excel? "NEW" means that I will not?)
xlsWB = xlsApp.ActiveSheet
'xlsWB = xlsApp.Workbooks.Open("c:\myWB.xls")
xlsSheet = xlsWB.Worksheets(1)
The code above "works" in VB.NET Visual Basic but I'll be in a NEW instance of Excel. Yes/No?
TIA for any thoughts. EagleOne