ShellExecute API
am 30.01.2008 17:52:34 von John Smith
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======
Re: ShellExecute API
am 30.01.2008 19:04:58 von JohnH
On Jan 30, 8:52 am, "John Smith" 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.
Re: ShellExecute API
am 30.01.2008 21:45:08 von John Smith
Thank you... worked great!!!
"JohnH" wrote in message
news:596279aa-2689-4dc5-b378-0408f5b85aeb@1g2000hsl.googlegr oups.com...
> On Jan 30, 8:52 am, "John Smith" 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.