|
-
Apr 7th, 2007, 10:20 PM
#1
Thread Starter
Junior Member
[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.
Last edited by TheT; Apr 8th, 2007 at 10:44 AM.
-
Apr 7th, 2007, 10:30 PM
#2
Addicted Member
Re: Common Dialog Control Problem with .InitDir
post the code, but that sounds kinda strange... it usually accepts the changes, i think...
-
Apr 8th, 2007, 03:55 AM
#3
Re: Common Dialog Control Problem with .InitDir
 Originally Posted by TheT
I can post the code if it's needed. 
Please do...I can't replicate this problem.
-
Apr 8th, 2007, 09:12 AM
#4
Thread Starter
Junior Member
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
-
Apr 8th, 2007, 10:08 AM
#5
Member
Re: Common Dialog Control Problem with .InitDir
I guess it's a bug. See this.
-
Apr 8th, 2007, 10:13 AM
#6
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 8th, 2007, 10:44 AM
#7
Thread Starter
Junior Member
Re: Common Dialog Control Problem with .InitDir
 Originally Posted by minor28
I guess it's a bug. See this.
That did the trick, thanks Minor28!
-
Apr 8th, 2007, 06:56 PM
#8
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|