Re: FileDialog browse button: how do you specify the default directory

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:egbadZ4$FHA.3136@xxxxxxxxxxxxxxxxxxxxxxx
> THe FileDialog object is worse than useless. Its problems include:
> - Breaks the entire application as you switch version (references issue).

I think that's just a problem with the constants. Not real hard to replace
the constants with actual numbers if it gives you problems.

> - Does not work in runtime apps.

Isn't that throwing the baby out with the bath water?

> - The SaveAs option is offered, but does not work at all.

Does that mean that it doesn't return to you what name the user chose to
save something under? If not, it's just a dialogue, not a saving
application...you have to work out the saving yourself, just like when you
use the dialogue to pick a file or folder.

> A better solution is to use the API calls in this link:
> http://www.mvps.org/access/api/api0001.htm

That's really bloated and confusing code. Not surprising many people choose
to avoid it.

Might I suggest something more like this...?

Sub GetFile(Control)
Dim retFile As String, dlg As Variant, s As String
Set dlg = Application.FileDialog(msoFileDialogFilePicker) 'could use 3
instead of the constant
With dlg
.InitialFileName = CodeProject.Path
If .Show = -1 Then s = .SelectedItems(1)
End With
If s <> "" Then
retFile = Right(s, Len(s) - InStrRev(s, "\"))
Control.Value = retFile
End If
End Sub


.



Relevant Pages

  • Re: Allow User to Select Path of Import File
    ... Sub GetFile ... Dim retFile As String, dlg As Variant, s As String ... > the moment I've tested with a fixed path in the code and the import works ...
    (microsoft.public.access.externaldata)
  • Re: FileDialog browse button: how do you specify the default directory
    ... >That's really bloated and confusing code. ... >Sub GetFile ... > Dim retFile As String, dlg As Variant, s As String ...
    (microsoft.public.access.formscoding)
  • Re: File Browse
    ... I found this thread and the sub routine Amy has posted is perfect. ... Dim retFile As String, dlg As Variant, s As String ...
    (microsoft.public.access.forms)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)
  • Re: FTP CD command
    ... My code connects to a ftp site and the enumerates all content on that place ... Public Property UriAs String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ...
    (microsoft.public.dotnet.languages.vb)