Thread: ShellExecute
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1943_] Rick Rothstein \(MVP - VB\)[_1943_] is offline
external usenet poster
 
Posts: 1
Default ShellExecute

Try it this way...

Sub Macrosh()
x = Shell("cmd.exe /k C:\start.lnk", 1)
End Sub

I changed the /c to /k... doing that should keep the Command window open so
you can read any error messages that might have been generated. Knowing what
the error is (assuming there is one) should give you a hint at what you will
need to change.

Rick


"Dave Unger" wrote in message
...
Hi Gary's Student,

Thanks for your reply. This isn't working for me either, but maybe I
can see what's happening now (although I don't know why). The cmd
window flashes opens and immediately closes without running the file.
I think this was happening with my original routine, just too fast to
see. I tried this with Excel 97 as well (same machine), with the same
results. I'm starting to wonder if it might be a registry problem.
Anu other suggestions?

regards,

DaveU



On May 15, 7:21 pm, Gary''s Student
wrote:
Hi Dave:

Shell is usually not useful to start a file without specfying the app. But
rather than using the ShellExecute API, you can still use Shell as in this
example:

Sub Macrosh()
x = Shell("cmd.exe /c C:\start.lnk", 1)
End SuB

This will start an app/file associated with the shortcut on C: folder.

That is because cmd.exe is smart enough to:
1. look at the shortcut
2. find the target file
3. pick the correct app
4. open the file
--
Gary''s Student - gsnu2007h