p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Pro VB 6 (http://p2p.wrox.com/forumdisplay.php?f=73)
-   -   How do I debug an ActiveX DLL referenced by Excel? (http://p2p.wrox.com/showthread.php?t=15598)

James Diamond July 19th, 2004 04:01 AM

How do I debug an ActiveX DLL referenced by Excel?
 
Help!

I am writing a DLL with VB6 that is used by an Excel spreadsheet. When I run the spreadsheet, it passes values from the sheet to functions in the DLL. The DLL stores hundreds of values in arrays.

What is the best way of seeing those values? Currently I am writing additional "debug" functions to write the values back to the spreadsheet, but this is dreadfully time-consuming.

Is there a debugger that will enable me to interrogate variable arrays etc. in the DLL *during* the running of the VBA in the spreadsheet?

Your guidance is appreciated.

Thanks.

James

//##

andyirvine July 19th, 2004 05:45 AM

James,
Generally the best way to expose data from an encapsulated array is via an Item Property

Option Explicit
Private m_strItem As String
Private m_Items() As String


Public Property Get Item(lngIndex) As String

    If lngIndex >= 0 And lngIndex >= UBound(m_Items) Then
        Item = m_Items(lngIndex)
    End If

End Property

Public Property Let Item(lngIndex, ByVal strItem As String)

    If lngIndex >= 0 And lngIndex >= UBound(m_Items) Then
        m_Items(lngIndex) = strItem
    Else
        ' Need check for Redimming the Array etc

    End If

End Property


James Diamond July 19th, 2004 05:59 AM

Thanks, but that is in effect what I'm doing, and it's not appropriate because of the sheer number of arrays to look at.

I need a debugging environment.

I know that you can debug a DLL if you are referencing it in a VB exe (you use the test procedures for an out-of-process component). However, I can't see how to debug my DLL while referencing it from an Excel spreadsheet (which is what I need to do).

Please can anyone help?


andyirvine July 19th, 2004 09:51 AM

James,
You can use the VB IDE i.e. Start VB, open the dll's project and run the dll. Then open Excel and run your routine. VB should then re-direct calls from the dll to the running vbp, where you can step through the code and print to the Debug window. Nb Your dll vbp must be running before you open the Excel Workbook.
a:

marcostraf July 19th, 2004 01:05 PM

Hello James,
start VB and load the dll. If you did not make it already, build the project so the dll gets registered. Got to Project/Properties and open the Debug tab. Check the "Start Program" button and enter fullPath\excel.exe (or select it via the ... button.
Set any breakpoints you want.
Now run Excel and keep its window small so you can still see VB and wait for the first breakpoint.


All times are GMT -4. The time now is 02:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.