Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

why is this shellexecute failing?

Status
Not open for further replies.

gusset

Technical User
Joined
Mar 19, 2002
Messages
251
Location
GB
i am trying to open a file in my default tif viewer but am having patchy results.

sometimes it works and sometimes it doesn't. the worst thing is that it was working yesterday and not today - and there was no change to the program or the network in the meantime.

i can't see anything wrong with the syntax. the filename and path is fine, because i can paste it into windows explorer and the image loads in the default viewer. however, the return value of the function is 2 (bad file path).

has anyone battled with this issue before, and succeeded, or even failed and knows why?

thanks!
 
in case it makes a difference, here is the syntax:

lngRetVal = ShellExecute(0, "open", strFullTifPath, _
vbNullString, vbNullString, vbNormalFocus)
 
i have noticed that if i pass in a UNC (\\MyServer\) rather than a mapped path (to my H:\ drive), it works (but not on all machines).

clearly, there is something going on that i don't know about.

waaaah

g
 
thanks, norris. i am using shellexecute rather than shell so that i can run the code several times and the document will load into the existing instance of the shelled application.

i am under the impression that shell doesn't allow this, though i haven't tried it yet.

i found on the knowledge base a reference to spaces in the path messing things up - to the OS, it looks like command-line-type arguments. of course, i have my path/UNC in double-quotes to counter this problem.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top