Photo capture date - VBA

Solved
jean pétévé -  
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   -
Hello,

How to extract the date a photo was taken using VBA?

With the properties of the Folder object (DateCreated, DateLastModified, DateLastAccessed -
see http://www.commentcamarche.net/contents/vbscript/vbs-folder.php3),
I can extract the file's creation and modification dates, but not the date the picture was taken.

Additionally,
1/ in the properties of the photo (.jpg), in the Details tab:
* date taken is in the "Origin" section
* creation date and modification date are in the "File" section

2/ the photos were taken with 2 different cameras
* from CANON (photo saved on the computer via the memory card),
in this case the date taken is the same as the file creation date (so I have no problem)
* from SONY (photo saved on the computer from the camera via a cable),
in this case
the date taken is the date the photo was taken
the file creation date is the date the photo was saved on the computer

Thank you in advance

Configuration: Windows Vista / Firefox 5.0

3 réponses

pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 771
 
Hello,
It is possible to list the properties contained in the summary tab:
<My sources>
!!!Activate the reference: "Microsoft Shell Controls and Automation"!!!
In VBE: Tools/References
Sub ListeProprietesFichiers_getDetailsOf() 'source: 'http://www.microsoft.com/resources/documentation/windows/2000/server/ 'scriptguide/en-us/sas_fil_lunl.mspx ' 'Requires enabling the Microsoft Shell Controls and Automation reference ' Dim objShell As Shell32.Shell Dim strFileName As Shell32.FolderItem Dim objFolder As Shell32.Folder Dim Resultat As String, Reponse As String Dim i As Byte Set objShell = CreateObject("Shell.Application") 'Target directory Set objFolder = objShell.nameSpace("C:\Documents and Settings\michel") 'Loop through all items in the directory For Each strFileName In objFolder.Items 'To ensure folders are not taken into account If strFileName.isFolder = False Then Resultat = "" For i = 0 To 34 If objFolder.getDetailsOf(strFileName, i) <> "" Then _ Resultat = Resultat & objFolder.getDetailsOf(objFolder.Items, i) _ & ": " & objFolder.getDetailsOf(strFileName, i) & vbLf Next Reponse = MsgBox(Resultat & vbLf & vbLf & "Do you want to continue?", vbYesNo) If Reponse = vbNo Then Exit Sub End If Next End Sub

TO ADAPT: the path to your directory.
Test it and let me know if it lists the correct properties... I doubt it but...
--
Best regards,
Franck P
0
jean pétévé
 
Thank you pijaku, that's exactly what I needed.

By adding the indexes in the message box, I was able to find the one for the property that interests me.
0
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 771
 
If you have any difficulty listing this in Excel, don't hesitate.

P.S.: It's a good thing you found the corresponding property because otherwise, the method would have been much more arduous...
0
lvlat Posted messages 1 Status Membre
 
Hi, in case you are still following this thread: I am also using this piece of code, but in my dialog box I end up with
Year: Year
Name: Name
etc.

Why don't I have the values after the :? Yet I did a faithful copy/paste...

Thank you.
0
pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 771
 
Hello,
I have absolutely no idea why...

I'm using this piece of code too With what types of files?
0