473,811 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ShellExecute API

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.dl l" Alias
"ShellExecu teA" (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_Clic k()
Dim strImageName As String

strImageName = Me!txtImageNote
ShellExecute 0, vbNullString, strImageName, vbNullString, vbNullString,
vbNormalFocus
End Sub
=====END======
Jan 30 '08 #1
2 10744
On Jan 30, 8:52 am, "John Smith" <some...@micros oft.comwrote:
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.dl l" Alias
"ShellExecu teA" (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_Clic k()
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.dl l" Alias
"ShellExecu teA" (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.
Jan 30 '08 #2
Thank you... worked great!!!

"JohnH" <Jo**********@g mail.comwrote in message
news:59******** *************** ***********@1g2 000hsl.googlegr oups.com...
On Jan 30, 8:52 am, "John Smith" <some...@micros oft.comwrote:
>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.dl l" 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_Clic k()
Dim strImageName As String

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

This works for me:

Private Declare Function ShellExecute Lib "shell32.dl l" Alias
"ShellExecu teA" (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.

Jan 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2568
by: Marcel Sammut | last post by:
Greetings, I am converting a VB6 application to .net and am having troubles trying to print a document directley to the printer. My VB6 app used the API ShellExecute method to accomplish this, however, needed the printer name, driver and port. All which were obtainable using the Printer object in VB6. Now in .net, I've tried using the System.Drawing.Printing namespace to do this, but that is unsatisfactory. So I went back to the API...
3
5475
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and shdocvw.dll. And there comes the problem. I reference the libraries from my project. For this to work, I put the libraries in the same directory as the application. Now, from my code I try to ShellExecute to a link (to show it in a new window):
1
2315
by: MCzajk | last post by:
Is there a function similar to ShellExecute, which I can hook to when the program is started using Start Menu icon? MCzajk
11
81736
by: Le, Thanh-Nhan | last post by:
Hi, Is there a same function in .Net as API shellexecute? Thanks Nhan
0
1837
by: the_openFace | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd, string lpOperation, string lpFile,
0
1600
by: the openBack | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd, string lpOperation, string lpFile,
0
1860
by: David | last post by:
We have an mfc application in which we use ShellExecute to launch the browser with an initial web site. {ShellExecute( NULL, "open", "http://www.SomeWebSite.com", NULL, NULL, SW_SHOWNORMAL ) } This always worked without problems until... We have modified the application so that it now contains some managed C++ and C# code (in dll's). The call to ShellExecute is in an unmanaged C++ dll. When trying
4
3431
by: fdmaxey | last post by:
I currently start a target executable written in VB.Net from an application that uses a C-script language. I start the target executable using ShellExecute in the C-script. The target runs fine like this except for the fact that the target can't write to a log file. If I run the target independently of the C-script application, the log file is created and written to without a hitch. There is no error produced - the log file just...
1
3101
by: bugs bunny via .NET 247 | last post by:
Does anyone have actually used SetWindowsHookEx() to hook upShellExecute() so as to find what application was started bywindows or which folder is currently browsed by explorer. I knowone thing and that is ... Windows uses ShellExecute() to doalmost every task. I need some implementation help. I want to trigger an userdefined function when suppose Notepad is opened or in simplecase a messagebox that says Notepad has started. If anyone has a...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.