How can I use VBA to retrieve the picture property “Date Picture Taken”
I am able to use the FileSystemObject library to retrieve the the following properties:
“Date Created”
“Date LastModified”
“Date LastAccessed”
Thanks
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Picture Property (VB / VBA 2003)
I don’t know if FSO has (direct) access to this property. It’s part of the EXIF data embedded in the JPEG header information. You could try to programatically parse through the header, but it’s probably easier to use a free command line tool like ExifTool by Phil Harvey. Get the version that DOES NOT require Perl to be installed. There’s a bit of a learning curve on the subject of EXIF tags, pretty well covered on this site, but worth pursuing if you’re going to be working with digital photos.
Alan
Here is a function you can use to retrieve extended properties of a file:
Function GetProperty(strFile, n)
Dim objShell
Dim objFolder
Dim objFolderItem
Dim i
Dim strPath
Dim strName
Dim intPos
On Error GoTo ErrHandler
intPos = InStrRev(strFile, “”)
strPath = Left(strFile, intPos)
strName = Mid(strFile, intPos + 1)
Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.Namespace(strPath)
Set objFolderItem = objFolder.ParseName(strName)
If Not objFolderItem Is Nothing Then
GetProperty = objFolder.GetDetailsOf(objFolderItem, n)
End If
ExitHandler:
Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell = Nothing
Exit Function
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Function
The date a picture was taken happens to be property #25, so you can use
Debug.Print GetProperty(“C:PicturesMyHouse.jpg”, 25)
And here is a list of the values for n you can use in the function from my previous reply. Obviously, not all properties will be filled for all files (16-22 are for MP3 files, 24-26 for JPG files). Properties 27-29 may be used for custom purposes.
0 | Name |
1 | Size |
2 | Type |
3 | Date Modified |
4 | Date Created |
5 | Date Accessed |
6 | Attributes |
7 | Status |
8 | Owner |
9 | Author |
10 | Title |
11 | Subject |
12 | Category |
13 | Pages |
14 | Comments |
15 | Copyright |
16 | Artist |
17 | Album Title |
18 | Year |
19 | Track Number |
20 | Genre |
21 | Duration |
22 | Bit Rate |
23 | Protected |
24 | Camera Model |
25 | Date Picture Taken |
26 | Dimensions |
27 | (Not used) |
28 | (Not used) |
29 | (Not used) |
30 | Company |
31 | Description |
32 | File Version |
33 | Product Name |
34 | Product Version |
In addition to Hans’s neat code, I remembered I had a class/dll for VB6 that allows you to pass a file name and return an object which contains all Exif tags in a JPEG file. Below is an example using this class in VB6:
Dim objExif as New ExifReader Dim txtExifInfo as String objExif.Load "C:Path_To_Jpg.jpg" txtExifInfo = objExif.Tag(DateTimeOriginal) MsgBox txtExifInfo
Alan
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications