Link to home
Start Free TrialLog in
Avatar of bretbel
bretbel

asked on

File Explorer Manipulation

I would like to programmatically code Access to capture all the filenames in any particular File Explorer file folder and place the filenames in a table.  Also have the ability to rename a filename or even delete a file.  I remember in a past project of mine being able to do this in Excel.
Avatar of frankytee
frankytee
Flag of Australia image

use the filesystem object,
make sure you have registered the ocx file wshom.ocx
in a code module, go to tools->reference and check  "windows script host object model"

then
    Dim fso As FileSystemObject
    Dim fld As Folder
    Dim file As file
   
    Set fso = New FileSystemObject
    Set fld = fso.GetFolder("c:\whateverfolder\")
    For Each file In fld.Files
        'do whatever, insert into acces table etc
        MsgBox file.Name 'example only
   
    Next file
   
    Set fso = Nothing
   
ASKER CERTIFIED SOLUTION
Avatar of frankytee
frankytee
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bretbel
bretbel

ASKER

Wonderful Wonderful!  Worked perfectly, I inserted recordset code to add each filename into a table also.  Do you know how to display a .jpg file in an Access form?
do you mean simply show as an image on a form or embedded in a field?

if simply a static image then in form design, make sure to wizard is selected in the control toolbox then  insert an "image" control then follow the instructions
if embedded/ilnked in a field, in table design add a new field of type "OLE Object", then in table datasheet view, go to menu  insert ->object-> then follow instructions to either embed or link to image, new/existing etc etc.
if you link then if you distribute your app you need to ensure that the images and directory structure are available etc
Avatar of bretbel

ASKER

perfect.. thanks