Picking up file created date from browse event (1 Viewer)

matt beamish

Registered User.
Local time
Today, 07:05
Joined
Sep 21, 2000
Messages
199
Dear all,
I am using the below, on a click event to link images to records, and the code works fine.

Code:
Private Sub Command5_Click()
    Dim f As Object
    Dim strFile As String
    Dim strFolder As String
    Dim strFolderlo As String
    Dim varItem As Variant
   
    Set f = Application.FileDialog(3)
   
    f.AllowMultiSelect = True
    If f.Show Then
        For Each varItem In f.SelectedItems
            
            strFile = Dir(varItem)
            strFolder = Left(varItem, Len(varItem) - Len(strFile))
            strFolderlo = Replace(strFolder, "HiResPath", "LoResPath")
            MsgBox "Folder: " & strFolder & vbCrLf & _
                "File: " & strFile
        Next
    End If
    
  If Not strFolder Like ("*" & "HiRes" & "*") Then
  MsgBox "The image is not located in a file/folder structure as instructed and will not be linked."
  Exit Sub
 
  Else
    
 Me.Filename = strFile
 Me.LoResPath = strFolderlo & strFile
 Me.HiResPath = strFolder & strFile
       
    
End If
   
    Set f = Nothing
    
    
End Sub


I would like to also pick up the created date for each file, and have found this code in the Dev Centre

Code:
Sub ShowFileInfo(filespec)
    Dim fs, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    s = "Created: " & f.DateCreated
    MsgBox s
End Sub

Can someone show me how I might be able to mash these together?
I did have a go, and got a serious corruption (which I very rarely suffer). I'm not totally sure the corruption was due to my poor coding. Possible related was my database dropping a link to "Windows Script Host Object Model" which is used in a module. Might there be a conflict between that reference and "Scripting.FileSystemObject"?

TIA

Matt
 

isladogs

CID VIP
Local time
Today, 07:05
Joined
Jan 14, 2017
Messages
14,016
See if my Folder Image Viewer app is any use as I do something very similar including grabbing date created, date modified, file size & dimensions
 

matt beamish

Registered User.
Local time
Today, 07:05
Joined
Sep 21, 2000
Messages
199
Thanks for this Colin. I like the way you've used the ListtoTable functions this way. I have several old nightly routines that run the Allen Browne functions from batch files to build file lists, and I hadn't thought of using them On Click, reverting instead to Command Line Dos or PowerShell shenanigans.

So thanks again.
Matt
 

isladogs

CID VIP
Local time
Today, 07:05
Joined
Jan 14, 2017
Messages
14,016
Hi Matt
You're welcome.
Its so long since I created this that I'd forgotten what code I used.
One word of warning. If the folder also contains non-image files these will currently be included in the list and trigger an error in GetFileAttributes.
I'll post an update to fix that in the near future
 

isladogs

CID VIP
Local time
Today, 07:05
Joined
Jan 14, 2017
Messages
14,016
Attached is an update to the folder image viewer which (hopefully) fixes the issues I mentioned in my last post.
I've also added optional support for images in subfolders using a checkbox.

NOTE: the only file types currently supported are bmp, gif, jpg, png, ico.
It is NOT currently designed for viewing video files

Feedback appreciated together with any suggested changes to the app
 

Attachments

  • FolderImages v3.1.zip
    134.1 KB · Views: 26

Users who are viewing this thread

Top Bottom