method Worksheets of object _Global failed

  • Thread starter Thread starter ndalal
  • Start date Start date
N

ndalal

Hi,

I'm seeing this run-time error in VB when I use the following code:

Dim ws As Worksheet
For Each ws In Worksheets ' this line throws the run-time
error
:


I tried using these statements at the beginning of the function
ActiveCell.Activate and/or DoEvents or putting a delay, but that didn't
help.
I also tried using Excel.Application.Worksheets and other ways to use
worksheets,
but nothing works!

The above code is in a VB DLL, which is compiled and installed
correctly.

This problem happens only when I try to debug my application using
visual studio C++.
The problem does not happen if I run the application stand-alone or
debug it with VB.

Any help is appreciated.

Thanks,
- ND
 
Can someone please help with this problem?

More info is that when I put "Application" in VB watch window, I see
various objects like:
Worksheets : <Application-defined or object-defined error>

This happens ONLY when I debug my application using visual studio 6
C++. If I dont use C++ as debugging tool, then "Application" looks
fine...I'm really stucked !!

Thanks in advance.
 

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

Back
Top