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
Private Const SW_SHOWNORMAL = 1
Private Sub cmdSetRaceFile_Click()
'On Error GoTo ErrorHandler
Dim strFileName As String
Call Hourglass
cdlChangePath.Filter = "Race Files (*.*)|*.*"
cdlChangePath.InitDir = sPath
cdlChangePath.ShowOpen
strFileName = cdlChangePath.FileName
ShellExecute hWnd, "open", strFileName, vbNullString, vbNullString, SW_SHOWNORMAL
Call Arrow
Exit Sub
ErrorHandler:
Beep
ErrorHandler
ASKER
Private Sub cmdSetRaceFile_Click()
'On Error GoTo ErrorHandler
Dim strFileName As String
Call Hourglass
cdlChangePath.Filter = "Race Files (*.*)|*.*"
cdlChangePath.InitDir = spath
cdlChangePath.ShowOpen
Dim intBackSlash As Integer
With cdlChangePath
intBackSlash = InStrRev(.FileName, "\")
' If you want the last \
spath = Left$(.FileName, intBackSlash)
' if you don't
spath = Left$(.FileName, intBackSlash - 1)
End With
' If you don't want to actually do anything with the file then
' delete the next 3 lines
strFileName = cdlChangePath.FileName
ShellExecute hWnd, "open", strFileName, vbNullString, vbNullString, SW_SHOWNORMAL
Call Arrow
Exit Sub
ErrorHandler:
Beep
ErrorHandler
End Sub
ASKER
ASKER
Private Sub cmdSetRaceFile_Click()
With cdlChangePath
.CancelError = True
.Filter = "Race Files (*.*)|*.*"
.FilterIndex = 1
On Error Resume Next
.CancelError = True
.ShowOpen
If Err.Number <> 0 Then
MsgBox "No file was selected"
Exit Sub
End If
On Error GoTo 0
End With
End Sub
ASKER
ASKER
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY
sPath = <my new path>
Or you could simply to this in cmdSetRaceFile_Click
cdlChangePath.InitDir = <my new path>