Solved

VB6 Shell

Posted on 2011-03-17
2
564 Views
Last Modified: 2012-05-11
I have the following code working:

runExe = Shell("C:\Program Files\Jasc Software Inc\Paint Shop Pro 8\Paint Shop Pro.exe " & stored_file, vbMaximizedFocus)

And it opens the picture in Paint Shop Pro, like it's supposed to.  I would like to save a step if Paint Shop Pro is already open, but this doesn't work:

runExe = Shell(stored_file, vbMaximizedFocus)

I thought it would use whatever program is associated with the file type, in this case .jpg, but it isn't working.
0
Comment
Question by:hrolsons
  • 2
2 Comments
 
LVL 6

Expert Comment

by:rbgCODE
ID: 35162388
there is a special api you can use that will instead of using runEXE you actually call windows API to manage opening the file...

0
 
LVL 6

Accepted Solution

by:
rbgCODE earned 500 total points
ID: 35162395
wooops, forgot the code.. here it is.


Private Declare Function ShellExecute Lib "shell32.dll" 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

Public Sub xstart(xpath As String)
 Call ShellExecute(hWnd, "Open", xpath, "", App.Path, 1)
End Sub

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question