Can someone please tell me what I'm doing or not doing wrong?
I have the following module:
Then I have this attached to the field which contains the name of the file in text:
I'm getting the error "Unable to open...."
Please help.
I have the following module:
Code:
Option Compare Database
Option Explicit
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 nshowcm As Long)
Sub ShellToFile(strFolder As String, strFile As String, _
strExtension As String, ByVal lngHwnd As Long)
Dim lngRetVal As Long
Dim strPath As String
If Right(strFile, 3) <> strExtension Then
strFile = strFile & "." & strExtension
End If
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
strPath = strFolder & strFile
lngRetVal = ShellExecute(lngHwnd, "open", strPath, _
vbNullString, CurDir$, 1)
If lngRetVal < 32 Then
MsgBox "Unable to open file " & strPath, vbInformation, "Warning"
End If
End Sub
Then I have this attached to the field which contains the name of the file in text:
Code:
Private Sub Ctl2009_REPORT_Click()
On Error GoTo Err_Ctl2009_REPORT_Click
ShellToFile "V:\FCC Form 320 Reports\", Me.Ctl2009_REPORT, "pdf", hwnd
Exit_Ctl2009_REPORT_Click:
Exit Sub
Err_Ctl2009_REPORT_Click:
MsgBox Err.Description
Resume Exit_Ctl2009_REPORT_Click
End Sub
I'm getting the error "Unable to open...."
Please help.