Automation error

  • Thread starter Thread starter Bobby
  • Start date Start date
B

Bobby

Hello! Sirs,
I am running Excel 2003. I wrote a recovery procedure a .VBS
When executed the macro procedure I get the following message:

Run-Time error '-2147024894(80070002)'
The system cannot find the file specified

The file is in the same directory then the .XLS
This is the macro:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim thepath As String
Dim WSH As New IWshRuntimeLibrary.WshShell
thepath = "D:\xxxxxx\DOCUMENT\xxxxx xxxxx\Ultima\TEST\System
\recover.vbs"
WSH.Run thepath, , True
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Any suggestion will be appreciate!
Thank's ahead
 
I don't have a guess why that error occurs, but if the .vbs file is in the same
folder as the workbook that owns the code that's running, you could use this
line:

thepath = thisworkbook.path & "\recover.vbs"
 
I don't have a guess why that error occurs, but if the .vbs file is in the same
folder as the workbook that owns the code that's running, you could use this
line:

thepath = thisworkbook.path & "\recover.vbs"








--

Dave Peterson- Hide quoted text -

- Show quoted text -

First Dave thank you for your time!
I did try your suggestion but unfortunatly I get the same message!
The file is in the same directory than the .xls file
Any other suggestion?
 
If you pick up that piece of code and just paste it into a brand new workbook
(saved into the same folder), does it work?

(I still don't have a guess.)
 
If you pick up that piece of code and just paste it into a brand new workbook
(saved into the same folder), does it work?

(I still don't have a guess.)



Bobby wrote:

I created a Book1.xls in the same pasted the code and got the same
message!
 
Maybe you can test to see if that file is really there.

Dim TestStr as string
teststr = ""
on error resume next
teststr = dir(thisworkbook.path & "\recover.vbs")
on error goto 0

if teststr = "" then
msgbox "It's really not there!"
else
do your stuff
end if

=========
 
Maybe you can test to see if that file is really there.

Dim TestStr as string
teststr = ""
on error resume next
teststr = dir(thisworkbook.path & "\recover.vbs")
on error goto 0

if teststr = "" then
  msgbox "It's really not there!"
else
  do your stuff
end if

=========








--

Dave Peterson- Hide quoted text -

- Show quoted text -

Did the test and the file is showing there!
 
Did the test and the file is showing there!- Hide quoted text -

- Show quoted text -

Dave I did a test in the following Directory: C:\TEMP
and it worked!

So the conclusion is that there is something to do with the path. Here
is the path that I was using:

D:\Robert\DOCUMENT\Kelly services\Ultima\TEST\Système\recover.vbs

What is wrong with it? Is it the french accent in Système word?
(Frernch character)
 
Maybe it's the spaces in the path.

I'd try this next:

WSH.Run chr(34) & thepath & chr(34), , True

chr(34) is the double quote.

If that doesn't help, how about creating a different folder that has almost the
exact path name--except that Système is plain old Systeme (without tha
diacritical(?) mark.
 
Maybe it's the spaces in the path.

I'd try this next:

WSH.Run chr(34) & thepath & chr(34), , True

chr(34) is the double quote.

If that doesn't help, how about creating a different folder that has almost the
exact path name--except that Système is plain old Systeme (without tha
diacritical(?) mark.










--

Dave Peterson- Hide quoted text -

- Show quoted text -

As a matter of fact I just did rename the path without the accent and
it still did not work. So I believe it is the space in the name. Let
me try it.
 
As a matter of fact I just did rename the path without the accent and
it still did not work. So I believe it is the space in the name. Let
me try it.- Hide quoted text -

- Show quoted text -

Dave, your suggestion of using WSH.Run chr(34) & thepath & chr(34), ,
True ---> WORK!
I did rename back the work Systeme to Système and used the chr(34) and
it --> WORK TO!
So the conclusion of this is if spaces exist in a name directory, use
the chr(34)

Well this is it! Thank you again for your support!
 
I missed that space character the first few, er, lots of times.

Sorry about that.

But glad you got it working.
 
I missed that space character the first few, er, lots of times.

Sorry about that.

But glad you got it working.








--

Dave Peterson- Hide quoted text -

- Show quoted text -

Dave, beside your help on this manner I learned the following:
ThisWorkbook.Path that I did not know about and the use of the Chr
(34) ! So you made my day!
Take care!
 
Chr(34) is easier for me to remember/write.

But you could have used:
WSH.Run """" & thepath & """", , True

You have to double up the " to see one " inside a string.
 
Back
Top