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):
And this is form does not work at all:
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