ShellExecute and MS Photo Editor

N

Neil

I am using ShellExecute to open JPG files with the associated application,
MS Photo Editor, from within an Access 2000 application. When the code is
run the first time (Photo Editor closed), there's a blinking in my
application title bar, and nothing appears. Then, if I do it a second time,
Photo Editor appears, but with two copies of the image. And, as long as
Photo Editor stays open, the images open fine. But if it's closed, it takes
two times to get it open.

This doesn't happen with MS Picture and Fax Viewer as the default
application. With Picture and Fax Viewer, the same code opens it up
immediately. However, users have MS Photo Editor as their default app, and
they prefer it.

Anyone know what's going on with MS Photo Editor here? Code is below.

Thanks,

Neil

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 Function OpenFile(strPath As String, strFilename As String)

Call ShellExecute(Application.hWndAccessApp, "open", strFilename,
vbNullString, strPath, 0)

End Function
 
T

Tom Esh

I am using ShellExecute to open JPG files with the associated application,
MS Photo Editor, from within an Access 2000 application. When the code is
run the first time (Photo Editor closed), there's a blinking in my
application title bar, and nothing appears. Then, if I do it a second time,
Photo Editor appears, but with two copies of the image. And, as long as
Photo Editor stays open, the images open fine. But if it's closed, it takes
two times to get it open.

...
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 Function OpenFile(strPath As String, strFilename As String)

Call ShellExecute(Application.hWndAccessApp, "open", strFilename,
vbNullString, strPath, 0)

End Function

I don't have PhotoEditor here to test it, but part of the problem may
be the nShowCmd arg. 0 equates to SW_HIDE, so unless the app overrides
it (which PE apparently does not), you end up launching an instance
with no visible UI. Change it to SW_NORMAL (1) and see what happens.


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
 
G

Guest

Hi,
I read your post with great interest since I am trying to something similar.
I have a form with 16 image controls on it. I attach .jpg files to the image
controls as needed. What I want to do is be able to click on the an attached
picture and open MS Photo Editor to view the picture in a larger format.

I am new to VBA and am having problems getting you code to compile without
any errors. I use the ON_CLICK property of the image control to execute the
code. Then debugger is choking on the 'Private Declare Function' statement.

Please help. Below is the code as I am trying to run it in a sub-routine.

'
'declare function
Debug.Print "B1- Image 01 function declare"
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
'
'use openfile function
Debug.Print "B2- use open file function"
Public Function OpenFile(strPathName As String, strFileName As String)
'
'call private function to open MS Photo Editor
Debug.Print "B3- open photo editor"
Call ShellExecute(Application.hWndAccessApp, "open", strFileName,
vbNullString, strPath, 1)
'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top