Re: find and display files
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxx>
- Date: Tue, 15 Sep 2009 12:47:38 -0400
The ahtCommonFileOpenSave function has an optional InitialDir parameter.
Dim strFilter As String
Dim strFolder As String
Dim strInputFileName as String
strFolder = "C:\Folder\Subfolder\"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", _
Me!SomeTextBox & "*.PDF")
strInputFileName = ahtCommonFileOpenSave( _
InitialDir = strFolder, _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8D83F134-A902-4263-9036-7F73B02FABE4@xxxxxxxxxxxxxxxx
Sorry to be a pain, one further question - How can I direct the search to
look at a specific directory?
"gymphil" wrote:
Brilliant!
It works perfectly and is just want I wanted to achieve. The user inputs
the
first few characters into the textbox and those pdf files are displayed
for
selection, superb.
I sincerely appreciate your help and hope this information is helpful to
others.
Thanks again Doug
"Douglas J. Steele" wrote:
Sorry, but why? You've already got a way for them to select the PDF
file of
interest: why do you need to use a combo box instead?
That being said, the dialog can limit those PDF files returned based on
the
first 6 characters typed into a text box named SomeTextBox if you
change the
filter to
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)",
Me!SomeTextBox
& "*.PDF")
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B4769C3C-5E93-4391-952D-F037A3B82B5D@xxxxxxxxxxxxxxxx
Doug,
OK, I added the followhyperlink to the back of the code and it is now
opening the file I selected when prompted, great! Is it possibe
(rather
than
opening the whole directory) to just return the file (or files) with
the
first 6 characters that the user types into a text box? I know that I
cannot
use hyperlinks with wildcards and I cannot use AddItem in Access 2000
with
a
list box, is there another way? Ideally I would like to add these
files to
a
combo box or list box or subform so that the user can select the
required
file and open the pdf document.
Also, the combo box currently is inactive! it does not store the
string
variable.
Appreciate your help, I am still a novice!
"Douglas J. Steele" wrote:
You're absolutely right. All that code does is prompt the user to a
select a
file, and stores the full path to the selected file in a variable
(strInputFileName).
All the code you had before was going to do was put the names of the
files
into a combo box. Once the user selected a file from that combo box,
nothing
was going to happen unless you did something with the selection.
Assuming what you're trying to do is open the document in the user's
default
application (Adobe Reader, FoxIt, whatever), try
Application.FollowHyperlink strInputFileName
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D348CA11-F33F-4C60-B4FC-C46924824DF3@xxxxxxxxxxxxxxxx
Doug,
Thanks, I believe I have done what you suggested.
Don't know if I am missing the obvious but basically using a
command
button
I am now prompted to open pdf files in a directory, I can only
select
one,
but nothing happens!
What I am looking for is the user to input the first 6 characters
of
the
file name in a text field and somehow or another to view or browse
those
files that begin with those characters, and to select the required
file
to
open.
Apologies if I did not explain this properly.
"Douglas J. Steele" wrote:
Create a new module (not a class module nor a module associated
with a
form
or report).
Copy everything in the shaded area (between Code Start and Code
End)
into
that module.
When you save the module, make sure you don't name it the same as
any
subs
or functions in it. (calling it something like mdlFileDialog
would
probably
be a good idea)
Where you want to invoke the dialog, use code like the sample at
the
top
of
the page. To find only PDF files, you'd use something like
Dim strFilter As String
Dim strInputFileName as String
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)",
"*.PDF")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
strInputFileName will contain the complete path to the file they
select.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CE4E1712-4EA7-45FF-823E-C021C289D7AA@xxxxxxxxxxxxxxxx
Doug,
Thanks for your advise, I have had a look a the link you gave
me,
not
sure
what to do with the code but I will try and work it out.
many thanks
"Douglas J. Steele" wrote:
As I mentioned else-thread, the AddItem method wasn't
introduced
until
Access 2002, so you won't be able to use that code.
Can you present them with the standard Windows File Open/File
Save
dialog
instead? See http://www.mvps.org/access/api/api0001.htm at
"The
Access
Web"
for a complete example.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C46CC2BE-498F-43E3-A219-A4D0A51B9B0C@xxxxxxxxxxxxxxxx
Thanks for your prompt response.
I am using access 2000.
Basically I want to find files in a 'C' directory using data
from
a
control
on a form, but I need to combine this with a wild card. I
initally
wanted
to
use hyperlinks but cannot use wildcards in hyperlinks, so I
want
to
extract
the file names and somehow add them to a list box or perhaps
a
form
so
the
the user can select the correct and full file as perhaps a
hyperlink
to
open
a pdf file. I am not sure what is the best way to achieve
this
but
need
to
use a wildcard as the file names in the database do not
match the
files
names
in the 'C' drive.
Hope this makes sense.
Many thanks
"MikeB" wrote:
What version of Access.. "AddItem" not supported in
earlier
versions
of
Access.
"gymphil" <gymphil@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:94657DDF-BE10-4EA7-9922-6BEC66EB6FC4@xxxxxxxxxxxxxxxx
Can anyone assist?
I am trying to search a directory that contains pdf
files, I
have
found
a
bit of code that I thought might achieve what I want to
do:
Set fs = Application.FileSearch
With fs
.LookIn = "\\publication order"
.Filename = Me.Text0
.Execute
If Len(.Filename) > 0 Then
For i = 1 To .foundfiles.Count
Me.List2.Additem (.foundfiles(i))
Me.List2.i
Next i
End If
End With
The idea is to populate a listbox 'list2' with the files
found
using
part
of
the file name, I am getting a compile error - method or
data
member
not
found
(.Additem)
Many thanks
.
- Follow-Ups:
- Re: find and display files
- From: gymphil
- Re: find and display files
- References:
- find and display files
- From: gymphil
- Re: find and display files
- From: MikeB
- Re: find and display files
- From: gymphil
- Re: find and display files
- From: Douglas J. Steele
- Re: find and display files
- From: gymphil
- Re: find and display files
- From: Douglas J. Steele
- Re: find and display files
- From: gymphil
- Re: find and display files
- From: Douglas J. Steele
- Re: find and display files
- From: gymphil
- Re: find and display files
- From: Douglas J. Steele
- Re: find and display files
- From: gymphil
- Re: find and display files
- From: gymphil
- find and display files
- Prev by Date: Re: How to force Spellcheck?
- Next by Date: how to transfer balance from one *** to another
- Previous by thread: Re: find and display files
- Next by thread: Re: find and display files
- Index(es):
Loading