[Solved] Common Dialog Control Problem with .InitDir
I can't seem to get .Initdir to set the directory more then once, when I first call the Common Dialog Control to .Initdir to app.path it does it, however if I do it again it goes to the directory it was last in opposed to app.path.
I can post the code if it's needed. :)
Re: Common Dialog Control Problem with .InitDir
post the code, but that sounds kinda strange... it usually accepts the changes, i think...
Re: Common Dialog Control Problem with .InitDir
Quote:
Originally Posted by TheT
I can post the code if it's needed. :)
Please do...I can't replicate this problem.
Re: Common Dialog Control Problem with .InitDir
Code:
Private Sub btn_addobj_Click()
On Error GoTo ErrorHandler
With cdc_add
.InitDir = App.Path
.CancelError = True
.DialogTitle = "Open File"
.Filter = "All Files (*.*)|*.*"
.ShowOpen 'Show the open file dialog.
obj(Numofobj) = .FileName
MsgBox obj(Numofobj) 'Display Info
lis_obj.AddItem (.FileName)
Numofobj = Numofobj + 1 ' Increase by 1
.InitDir = App.Path
End With
Exit Sub
ErrorHandler:
If Err.Number = 32755 Then
'User pressed cancel.
MsgBox "User pressed cancel", vbInformation
Else
'Some other error.
MsgBox Err.Description, vbExclamation, "Error (#" & Err.Number & ")"
End If
End Sub
Re: Common Dialog Control Problem with .InitDir
I guess it's a bug. See this.
Re: Common Dialog Control Problem with .InitDir
Either that or its only meant to "initially" set the path when its first called in tha instance of the running of the program.
I did this and it works only the very first time. Hence - "Initial directory".
vb Code:
Option Explicit
Private Sub Command1_Click()
'Forces the dialog box to set the current directory to what it was when the dialog box was opened.
CommonDialog1.Flags = cdlOFNNoChangeDir
CommonDialog1.InitDir = "C:\"
CommonDialog1.ShowOpen
End Sub
Re: Common Dialog Control Problem with .InitDir
Quote:
Originally Posted by minor28
I guess it's a bug. See
this.
That did the trick, thanks Minor28!
Re: [Solved] Common Dialog Control Problem with .InitDir
Thanks for letting us know you have your answer. The next time you may find it easier to do that by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button.