I have the following code, which calls the Common File Dialog Box, for the selection of a file. The function returns a filename that is then passed to a CreateObject script I found, and opens the file using Adobe Acrobat.
The problem is that if the Common File Dialog Box is cancelled, or no file is selected, Adobe Acrobat still opens...but with no file. The code works fine, but the application opening on a cancelled action is annoying.
Does anyone know of a simple way to halt the operation if a file isn't selected?
Thanks.
_______________________________
Private Sub Command59_Click()
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an file...", _
Flags:=ahtOFN_HIDEREADONLY)
If IsNull(strInputFileName) Then
Exit Sub
Else: CreateObject("WScript.Shell").Run "acrobat """ & strInputFileName & """"
End If
End Sub
The problem is that if the Common File Dialog Box is cancelled, or no file is selected, Adobe Acrobat still opens...but with no file. The code works fine, but the application opening on a cancelled action is annoying.
Does anyone know of a simple way to halt the operation if a file isn't selected?
Thanks.
_______________________________
Private Sub Command59_Click()
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an file...", _
Flags:=ahtOFN_HIDEREADONLY)
If IsNull(strInputFileName) Then
Exit Sub
Else: CreateObject("WScript.Shell").Run "acrobat """ & strInputFileName & """"
End If
End Sub