Re: ShellExecute API



Thank you... worked great!!!

"JohnH" <JohnHarris34@xxxxxxxxx> wrote in message
news:596279aa-2689-4dc5-b378-0408f5b85aeb@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jan 30, 8:52 am, "John Smith" <some...@xxxxxxxxxxxxx> wrote:
Hi,

I have an access database form with an image. I'm trying to create an
onclick event on the image so that when a user clicks on the image it
opens
that file with the default viewer the computer is set on. I've searched
the
web and nothing solid. I did get the following VBA code and it doesn't
seem
to work. If anyone can help me i'd appreciate it. From the code below
txtImageNote is a field on the form that displays the path to the image
with
is working properly.

=====BEGIN=====
Option Explicit
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

Private Sub imageFrame_Click()
Dim strImageName As String

strImageName = Me!txtImageNote
ShellExecute 0, vbNullString, strImageName, vbNullString,
vbNullString,
vbNormalFocus
End Sub
=====END======

This works for me:

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
----
ShellExecute 0&, vbNullString, sPath, vbNullString, vbNullString,
vbNormalFocus
----
...where sPath is a full valid path to a file.


.



Relevant Pages

  • Re: Create e-mail w/attachments *AND* subject/body thru own client
    ... > 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 ... > Private Sub Form_Load ...
    (microsoft.public.vb.winapi)
  • Re: Files launched w/ Followhyperlink open but not visible
    ... ByVal lpOperation As String, _ ... Dim lRet As Long, varTaskID As Variant ... 'First try ShellExecute ... stFile, vbNullString, vbNullString, lShowHow) ...
    (comp.databases.ms-access)
  • Re: Files launched w/ Followhyperlink open but not visible
    ... ByVal lpOperation As String, _ ... Dim lRet As Long, varTaskID As Variant ... 'First try ShellExecute ... stFile, vbNullString, vbNullString, lShowHow) ...
    (comp.databases.ms-access)
  • Re: Open a file in the same instance with ShellExecute
    ... vbNullString, vbNullString, vbNormalFocus ... Private Declare Function ShellExecute Lib "shell32.dll" Alias _ ... String, ByVal lpszFile As String, ByVal lpszParams As String, _ ... Dim hwnd As Long ...
    (microsoft.public.excel.programming)
  • ShellExecute API
    ... I have an access database form with an image. ... "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal ... Dim strImageName As String ... ShellExecute 0, vbNullString, strImageName, vbNullString, vbNullString, ...
    (comp.databases.ms-access)

Loading