dbTalk Databases Forums  

Windows 7 Explorer A2010

comp.databases.ms-access comp.databases.ms-access


Discuss Windows 7 Explorer A2010 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Windows 7 Explorer A2010 - 12-13-2009 , 04:50 AM






I am convertin from AK2 to A2010.
VBA routines which opened Windows explorer to find files or folders no longer
work (unsurprisingly) Can anyone help with a function to return the name of a
Library, Folder or file please I suspect it will look a bit like this
Public Function ExploreFor(WhatToLookFor As Integer, Optional WhereToLook As
String, WhatToLookFor As String) As String So WhatToLookFor say 1 for
Library, 2 for Folder, 3 for File E.G. MyFile = ExploreFor(3, "C:\My
Documents", "Mdb")

Thanks for any help

Reply With Quote
  #2  
Old   
Rich P
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-14-2009 , 05:26 PM






What is the code for the function body? Does this function just check
file extensions? Like if a given folder contains 20 files of which 3 of
the are .dll, 2 are .mdb, 6 are .xls, 4 are .pdf, and 5 are .txt

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 ***

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-14-2009 , 06:12 PM



On 14/12/2009 22:26:06, Rich P wrote:
Quote:
What is the code for the function body? Does this function just check
file extensions? Like if a given folder contains 20 files of which 3 of
the are .dll, 2 are .mdb, 6 are .xls, 4 are .pdf, and 5 are .txt

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

Reply With Quote
  #4  
Old   
Rich P
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-14-2009 , 06:47 PM



Hi 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.


Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #5  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-14-2009 , 08:58 PM



Rich is on the right track. You can use:

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
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #6  
Old   
Phil
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-15-2009 , 03:42 AM



On 14/12/2009 23:47:02, Rich P wrote:
Quote:
Hi 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.


Rich

*** Sent via Developersdex http://www.developersdex.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

Reply With Quote
  #7  
Old   
Phil
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-15-2009 , 05:59 AM



On 15/12/2009 01:58:39, "Albert D. Kallal" wrote:
Quote:
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

Reply With Quote
  #8  
Old   
Albert D. Kallal
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-15-2009 , 07:49 AM



"Phil" <phil (AT) stantonfamily (DOT) co.uk> wrote

Quote:
On 15/12/2009 01:58:39, "Albert D. Kallal" wrote:


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.

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...


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal (AT) msn (DOT) com

Reply With Quote
  #9  
Old   
Phil
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-15-2009 , 01:24 PM



On 15/12/2009 01:58:39, "Albert D. Kallal" wrote:
Quote:
Rich is on the right track. You can use:

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)


Thanks Albert

Spot on what I wnted, and so very simple

Phil

Reply With Quote
  #10  
Old   
David W. Fenton
 
Posts: n/a

Default Re: Windows 7 Explorer A2010 - 12-15-2009 , 05:16 PM



"Albert D. Kallal" <PleaseNOOOsPAMmkallal (AT) msn (DOT) com> wrote in
news:q3CVm.80878$W77.22569 (AT) newsfe11 (DOT) iad:

Quote:
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/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.