Get Pics by date taken

Posted on 2008-11-07
Last Modified: 2013-12-02
Ok lets see if i can explain this. I have a publisher file that has soem pic boxes on the document.  what we are doing now is double clicking on the Picture box and choosing the pic we want out of the directory and then going to the next box and doing the same thing. I would like to automate this with VB and have it ask me what directory then for it to grab each pic in that directory by the date and time taken and put them in order. Is this possible?
Question by:wcmash
    LVL 26

    Expert Comment

    Every file has a tag that contains the creation date of that file. You can select your file by using this property of the file...
    LVL 6

    Accepted Solution

    Get all files in the selected folder and store their details in an array; then order the array by the creation date. A simple example (VB2005 tested):

    Public Class FIDateComparer
    	Inherits Comparer(Of FileInfo)
    	Public Overrides Function Compare(ByVal x As System.IO.FileInfo, ByVal y As System.IO.FileInfo) As Integer
    		Return x.CreationTime.CompareTo(y.CreationTime)
    	End Function
    End Class
    Dim f As New List(Of FileInfo)
    Dim s() As String = Directory.GetFiles("c:\")
    For Each n As String In s
    	f.Add(New FileInfo(n))
    f.Sort(New FIDateComparer())
    For Each fi As FileInfo In f
    	Debug.Print(fi.Name & vbTab & fi.CreationTime)

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
    User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
    Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now