Thread: ShellExecute
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default ShellExecute

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


"Dave Unger" wrote:

Hello,

Running XP pro & Excel 2007

I was running this bit of code this morning to launch a shortcut on
the desktop, and everything was working fine. While experimenting
with variations things went into "lala land", and now I can't get it
to work again (with the original code). Reinstalling Excel didn't
help. It looks like it's going to launch the shortcut (mometary
hourglass), but the window never opens. Interestingly, it will still
launch a .bat file without any problem. My experience with API calls
is limited, any help would be most appreciated.

regards,

DaveU

Sub LaunchLNK()
Dim DeskTop As String
DeskTop =
CreateObject("WScript.Shell").SpecialFolders.Item( "Desktop")
ShellExecute 0, "Open", DeskTop & "\myfile.lnk", "", "C:\", 1
End Sub