You are here:

Excel/Access the Date Picture Taken attribute

Advertisement


Question
Hello,
Using VBA (Windows XP and Excel 2003) is it possible to retreive the value of the "Date Picture Taken" attribute of a picture file.

Thank you

Answer
If, for instance, you have on your drive a picture in .jpg format, you can use vba to retreive the date that .jpg file was created. This can also be done with any other type of file. Here's code that will prompt you to browse to a .jpg file, and will then put the date of that file in cell B2.

Before running the code, from within any module of the Visual Basic Editor, you should choose from the main menu Tools, References and make sure that "Microsoft Scripting Runtime" is checked.

Sub getFileDate()
 Dim filePath As String
 Dim fso As Scripting.FileSystemObject
 Dim file As Scripting.file
 filePath = Application.GetOpenFilename( _
   "Picture (*.jpg), *.jpg")
 Set fso = New FileSystemObject
 Set file = fso.GetFile(filePath)
 Range("b2") = file.DateCreated
End Sub
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

All Answers

Answers by Expert:


Ask Experts

Volunteer


Stuart Resnick

Expertise

I can answer any question relating to MS Excel formulas, or to programming with vba (Visual Basic for Applications) in the Excel environment

Experience

As a consultant, I've designed Excel tools since the 90s, working for the Federal Reserve Bank, AT&T, and (currently) Gap Inc.

©2009 About.com, a part of The New York Times Company. All rights reserved.