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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locating other application 1

Status
Not open for further replies.

HHaskel

Programmer
Jun 14, 2002
46
SE
A have a commandbutton in my Access application that starts Illustrator.
It looks something like this:

Code:
Private Sub cmdEditImage_Click()
    Dim stAppName As String

    stAppName = "C:\Program Files\Adobe\Illustrator 10\" & _
                "Support Files\Contents\Windows\" & _
                "Illustrator.exe """ & Me.txtImagePath & """"
    Call Shell(stAppName, vbNormalFocus)
End Sub

This works well, the problem is if the user have installed illustrator on D: or any other place.

What is the best way to find out where illustrator.exe is located, or can I start Illustrator in any other way?


/Hakan Haskel
 
When you shell an installed program you don't need to include its path since those details are stored in the registry. Just add the executable name and the image and the system will provide the rest. VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Thanks for your answer. If I try with Word or Excel it works as you say, but if I try with programs like Illustrator, Acrobat Reader or WinZip, I get "File not found".

This works:
Call Shell("excel.exe")

This programs don't work:
Call Shell("illustrator.exe") ' Illustrator
Call Shell("acrord32.exe") ' Acrobat Reader
Call Shell("winzip32.exe") ' WinZip

Any idea why? or can I start this programs i any other way?


/Hakan Haskel
 
If you have the path to the file you want to open you can use the 'ShellExecute' api function:

Code:
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function ShellExecute Lib "shell32" _
    Alias "ShellExecuteA" _
   (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

' sample calls:
Sub Test()

 ShellExecute(GetDesktopWindow, "Open", "acrord32.exe", "C:\readit.pdf", "", 1)

 ShellExecute(GetDesktopWindow, "Open", "Illustrator.exe", "C:\boat.ai", "", 1)

' I could only get winzip to work by using 
' the filename in place of the executable: 

 ShellExecute(GetDesktopWindow, "Open", "C:\npds.zip", "", "", 1)

End Sub
VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Thanks

Actually in this database I only want to start Illustrator so your example with ShellExecute works perfect for me, I just wanted to show my problem with the other programs.

Thanks again
Hakan Haskel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top