ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Access current active workbook from DLL (https://www.excelbanter.com/excel-programming/372432-access-current-active-workbook-dll.html)

hon123456

Access current active workbook from DLL
 
Dear all,
I will write a DLL by using Visual Basic. Then I will call
the DLL in Excel VBA. Some variables will be passed to the DLL from
VBA. After that, the DLL will get recordset from database will fill the

cells in current active workbook. My question is how can I access the
current active workbook from the DLL? As I know, there is Microsoft
Excel 8.0 Object Library for VB? If this library is used to access
the current active workbook,what is the code to access current active
workbook and sheet?

Thanks


NickHK

Access current active workbook from DLL
 
There are various objects you can work with :
ActiveWorkbook
ActiveSheet
ActiveCell

Depending how the DLL and Excel interact ;
- Excel passes criteria & Recordset object to DLL DLL queries DB and
receives data DLL passes back filled RS Excel fills range
The DLL does need to know anything about Excel; Excel and DLL need ADO.
- Excel passes criteria & start Range to DLL DLL queries DB and receives
data DLL fills data starting at passed range
DLL needs to know about Excel & ADO.

NickHK

"hon123456" wrote in message
ups.com...
Dear all,
I will write a DLL by using Visual Basic. Then I will call
the DLL in Excel VBA. Some variables will be passed to the DLL from
VBA. After that, the DLL will get recordset from database will fill the

cells in current active workbook. My question is how can I access the
current active workbook from the DLL? As I know, there is Microsoft
Excel 8.0 Object Library for VB? If this library is used to access
the current active workbook,what is the code to access current active
workbook and sheet?

Thanks





All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com