Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ShellExecute problems

Status
Not open for further replies.

NightZEN

Programmer
Apr 29, 2003
142
0
0
US
I am trying to use the shellExecute to open a .tif file in the default program for that machine. I am getting strange results however. I wrote and tested on a temporary machine in access 2002 and it worked fine. Now it works only after converting it to access 97, and only on one form. But on the second form, pressing the button results in no actions or errors.

Here is the code from the form that it works on in 97 (the code is the same from 97/2002):
Code:
Option Compare Database
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
Const SW_SHOWNORMAL = 1

Private Sub Command107_Click()
'uses the shell32.dll
On Error GoTo Error_Handle

Dim lngFetch As Long
Dim strPart As String
Dim strIR As String
Dim strFolder As String
Dim strDir As String
Dim strFile As String

strPart = Me.PartNumber
strIR = Me.InspecReportNumber
strDir = "C:\Scans\"
strFile = strDir & strPart & "\IR_" & strIR & ".tif"

lngFetch = ShellExecute(Me.hwnd, vbNullString, strFile, vbNullString, "C:\", SW_SHOWNORMAL)


GetOutADodge:
    Exit Sub

Error_Handle:
    MsgBox Err.Description
    Resume GetOutADodge
    
End Sub

And this is form does not work at all:

Code:
Option Compare Database
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
Const SW_SHOWNORMAL = 1


Private Sub cmbScanView_Click()
'uses the shell32.dll
On Error GoTo Error_Handle

Dim strPart As String
Dim strIR As String
Dim strFolder As String
Dim strDir As String
Dim strFile As String
Dim lngGet Ss Long

strPart = Me.PartNumber
strMR = Me.MRNumber
strDir = "C:\Scans\"
strFile = strDir & strPart & "\MR_" & strMR & ".tif"

lngGet = ShellExecute (Me.hwnd, vbNullString, strFile, vbNullString, "C:\", SW_SHOWNORMAL)

GetOutADodge:
    Exit Sub

Error_Handle:
    MsgBox Err.Description
    Resume GetOutADodge
End Sub
 
What is the value returned by the call to ShellExecute?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
That's a File Not Found error.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top