Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retriving External File name (like "MSysObjects")

Status
Not open for further replies.

RiderJon

Programmer
Aug 26, 2002
190
0
0
FR
Hello:

I have a bunch of word Files in the folder:
"C:\Documents and Settings\user1\My Documents\Project"

I have named each excel file with the "project name as the prefix". Say the project was "Finland". Then I'd have files

Finland-Jan Report.doc
Finland-Project Mid Report.doc
FinlandConstructionSummary.doc
FinlandDamageRpt.doc

Basically, it can be any name, but will always start with the Project name.

WHAT I WANT TO DO:
In ACCESS, I want to list those files in a text box automatically. Is there a function like the "MSysObjects" for retrieving the external file name and displaying them in a list box like shown below:
____________________________________
|Finland-Jan Report.doc |
|Finland-Project Mid Report.doc |
|FinlandConstructionSummary.doc |
|FinlandDamageRpt.doc |
|____________________________________|

Thank you










RiderJon
"I might have created ctrl+alt+del,
But Bill made it famous" - Dr. Dave
 
hi, theres a filesystemobject that can deal with files and folders, you'll need to add a reference to Microsoft Scripting Runtime - here's an example
Code:
Sub TestFileSysObj()
Dim fso As FileSystemObject
Dim fi As File
Dim fd As Folder

Set fso = CreateObject("Scripting.FileSystemObject")
Set fd = fso.GetFolder(fso.GetParentFolderName(CurrentDb.Name))

For Each fi In fd.Files
    Debug.Print fi.Name
Next fi
    
End Sub
 
Hi RiderJon,

Alternatively, you can use FileSearch.

Code:
[blue]With Application.FileSearch

    .NewSearch
    .LookIn = "C:\Documents and Settings\user1\My Documents\Project"
    .FileName = "Finland*.doc"
    .Execute

    For i = 1 To .FoundFiles.Count
        Debug.Print .FoundFiles(i)
    Next
    
End With[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
This is good info!

I currently use something similar to copy pictures from a floppy and save them under a new name in a directory on my server. It copies all JPG files. I would like to populate a multiselect box with the names and the select only the files to copy.

How would I popluate the listbox with the names? I think I can figure out the rest.
 
Hi jasonphillipstx,

It depends what version of Access you have. Prior to 2K2, you need to set the Listbox's RowSourceType Property to [blue]Value List[/blue] and the RowSource Property to a semi-colon separated list of items, for example [blue]"Pic1";"Pic2";"Pic3"[/blue].

I believe listboxes in 2002 have the [blue]AddItem[/blue] Method (but not the full range of methods as per Excel) which simplifies the process.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top