troubleshooting Question

VB6 Common Dialog Question

Avatar of Bob Schneider
Bob SchneiderFlag for United States of America asked on
Visual Basic Classic
12 Comments1 Solution156 ViewsLast Modified:
I'm using a common dialog in a vb6 program and I need to change the location that I am storing as sPath.  How can I do that with this code...I don't want to open any files, I just want to change the location of my default path (sPath).  (Also, whenever I use this code, once I close it, reopens a file dialog window.

Here is the variable declaration in the page head:
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

Here is the procedure:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros