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

Open in new window

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
    strFileName = cdlChangePath.FileName
    ShellExecute hWnd, "open", strFileName, vbNullString, vbNullString, SW_SHOWNORMAL
    Call Arrow
    Exit Sub

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
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