Thanks for any help
does this function return a count of file types contained in the
selected folder? It sounds like all you need is basic File I/O routines
with a little bit of string manipulation. Need to see the VBA code of
the function's body to be more specific
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Thanks Rich for coming back.
That's the problem, I haven't got any code.
In error I suugested I wanted the name of the file. I meant of course the
path.
I'm basically wanting a routine that will open Windows Explorer. The user
then points to a Library, Folder or File and the Function returns the full
path of what has been selected.
The initial line of the air code was just a thought about "prompting"
Explorer start to look in the most likely place and, if we are looking for
files, possible filter for certain types of files eg *.mdb or m*.doc
Phil
I only have Access2003 and I played around with the builtin FileDialog
but was not able to retrieve filenames with this (unlike Excel where the
builtin FileOpenDialog works very nicely). I expect this has been
fixed/improved in Acc2010. Try
With Application.FileDialog(msoFileDialogOpen)
.Show
End With
Maybe the intellisense will show Filename in the dropdown. This is
where you would get the FileName.
Or place the cursor on top of FileDialog and press F1 to get help on
that.
If acc2010 still doesn't have a builtin FileOpenDialog then one
alternative would be to try out the code from this site
http://www.mvps.org/access/api/api0001.htm
This is Allen Browne's site. He has a bunch of API code which works
quite well, except that there is a bunch more code that you have to deal
with. But this option should work if the simpler option is not
available (still) in Acc2010.
Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogOpen)
f.Filters.Add "text documents", "*.txt"
f.Show
If f.SelectedItems.count > 0 Then
MsgBox "file choose was " & f.SelectedItems(1)
Else
MsgBox "no file selected"
End If
The above would set the file filter to *.txt files...you can change that for
whatever you want...
You can also setup the starting dir as:
Dim f As FileDialog
Set f = Application.FileDialog(msoFileDialogOpen)
f.Filters.Clear
f.Filters.Add "Text documents", "*.txt"
f.InitialFileName = "c:\"
f.Show
If f.SelectedItems.count > 0 Then
MsgBox "file choose was " & f.SelectedItems(1)
Else
MsgBox "no file selected"
End If
And, you can also just select a folder by using:
Set f = Application.FileDialog(msoFileDialogFolderPicker)
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOO...@msn.com
Thanks Rich ,
That is where I started some time ago.
I used that routine in my access 2000 database with windows XP.
Unfortunately for it does not seem to work with access 2010 and windows
seven. Many thanks,
Phil
Thanks Albert
Spot on, and so simple.
In the unlikely event that I want to get the name of one of these new fangled
libraries, is there a way of doing that?
There does not appear to be a msoFileDialogLibrartPicker in the Object
Browser.
Not vital, more a matter of interest
Many many thanks
Phil
It like using dao recordsets.
Inteli-sense should display a drop down list...
Set f = Application.FileDialog(
Once you get to the above (after just typed in the last (, then type in a
ctrl-j
You should see a pop up list of possible options...
Thanks Albert
Spot on what I wnted, and so very simple
Phil
> Rich is on the right track. You can use:
>
> Dim f As FileDialog
I had originally thought this required a reference to the Office
library, but I see that FileDialog is a member of the
Access.Application object, so it won't require it. I note that this
was not the case in Access 2000 (I don't have A2002 to see if it was
introduced there). I do see that it's still in A2007.
However, given the experience with the FileSearch object (introduced
in Office 95/97, and removed from Office 2007), I worry about
depending on it always being there. Using the Windows API is going
to be future-proof, as opposed to using a wrapper around it provided
by the Access application, which could come and go with different
versions.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
You could be right, Davis
Would you be kind enough to let me have a copy of the functions.
The ones I use were written by Ken Gatz over 12 years ago
Thanks
Phil
> Would you be kind enough to let me have a copy of the functions.
> The ones I use were written by Ken Gatz over 12 years ago
In my apps I'm using the ADH97 versions. An earlier version of that
is what's on the Access Web
(http://mvps.org/access/api/api0001.htm). It's written against the
Windows API -- it's not going to be broken in future versions of
Windows because MS doesn't break its legacy APIs. Remember, DOS apps
compiled in 1982 or so still run on current versions of Windows, and
I don't expect that the Windows API will be omitted from whatever
replaces Windows some day.
That said, there very well may snazzier functionality in newer APIs,
or in using the wrapper object in Access, but I'd rather stick with
something that works and will continue to work as long as Windows
exists.
Thanks David
That is what I have used
Phil