Not recognizing a specific sheet the first time

A

avi

Hello,

I have encapsulated a piece of code in an EXE file and use it to
create a specific sheet in the active workbook [The code: RetVal =
Shell("C:\word\EzPaste©\exempledll\ActiveWbk.exe")].

The first time i refer to the specific sheet created, i get an
"subscript out of of range" error. But just after that, the sheet is
recognized.

When i put a MsgBox just after the RetVal, the sheet is recognized in
the first time.

When i use directly the encapsulated code in VBA. it works the first
time.

Could you help explaining what happens and how to overcome the
problem?

Thanks a lot
Avi
 
D

Dave Peterson

Maybe the external .exe program hasn't finished what it has to do???

Any chance you could just wait a bit before continuing:

RetVal = Shell("C:\word\EzPaste©\exempledll\ActiveWbk.exe")
application.wait now + timeserial(0,0,2)
'keep going


Hello,

I have encapsulated a piece of code in an EXE file and use it to
create a specific sheet in the active workbook [The code: RetVal =
Shell("C:\word\EzPaste©\exempledll\ActiveWbk.exe")].

The first time i refer to the specific sheet created, i get an
"subscript out of of range" error. But just after that, the sheet is
recognized.

When i put a MsgBox just after the RetVal, the sheet is recognized in
the first time.

When i use directly the encapsulated code in VBA. it works the first
time.

Could you help explaining what happens and how to overcome the
problem?

Thanks a lot
Avi
 

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