How to debug a VB dll used in Excel

P

PM

Hi !

My VBA code calls a VB6 dll.

At present, not knowing otherwise, I compile my dll in vb6 (using exit subs
in place of stop points), then open Excel and my workbook, try the dll and
so forth. This is painstakingly long.

There must be a better way, trying out the dll in VB without compiling it.
Anyone know how to ?
(I guess this is really a VB question...)

Thanks.
Pat
 
B

Bob Phillips

Pat,

This question was asked a couple of days ago.

You should be able to debug the VB6 DLL while calling its methods from
within VBA.

To do this, open the project in VB6, and step into it, and step through all
tyhe in itialisation code until it is fully initialised.

Then go to your VBA project, and step into that. Calls into the DLL will
then step into that project.

With this, you can set breakpoints, use the watch and immediate windows as
with any VB/VBA project.


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
M

merlin

PM said:
Hi !

My VBA code calls a VB6 dll.

At present, not knowing otherwise, I compile my dll in vb6 (using exit subs
in place of stop points), then open Excel and my workbook, try the dll and
so forth. This is painstakingly long.

There must be a better way, trying out the dll in VB without compiling it.
Anyone know how to ?
(I guess this is really a VB question...)

Thanks.
Pat

Not sure if this will help, but when creating a DLL for Excel or any Office
component, I always create an executable in VB which forces the DLL to do
exactly the same thing. This way I test my DLL first in VB, and if I'm sure
it works, I start writing the VBA-calls.

You can also create a class module in Excel first, put all your code in
there, and if you're sure it works, then put it in a DLL.

To answer your other question about 10 DLL's or 10 classes - I would prefer
1 DLL, since 10 different DLL's might be confusing for both user and you.
 
S

Stephen Bullen

Hi Pm,
My VBA code calls a VB6 dll.

At present, not knowing otherwise, I compile my dll in vb6 (using exit subs
in place of stop points), then open Excel and my workbook, try the dll and
so forth. This is painstakingly long.

There must be a better way, trying out the dll in VB without compiling it.
Anyone know how to ?
(I guess this is really a VB question...)

Start by opening the VB6 dll in VB6 and clicking Debug > Start with full
compile

Now switch to Excel and open the workbook. In the VBE, check Tools >
References to ensure the workbook is referencing the VB6 project (not the
dll).

Once done, I find that pressing F8 steps through both the VBA and VB6 code,
switching IDEs as appropriate.


Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top