Solved

Is it possible to change a cell to the creation date value of each xls file in a folder?

Posted on 2011-02-16
4
277 Views
Last Modified: 2012-05-11
I have a folder with many Excel workbook files, 2003 version, in each.
Each workbook file has the same format and the same two worksheet names.
One worksheet has a cell with a date in it.
Is it possible to write a macro in a new Excel file that will identify the creation date of each file within the folder and change the cell value within each of the files to the date that the file was created?
0
Comment
Question by:spar-kle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Ken Fayal
ID: 34912759
You should be able to assign the value of the cell you want to

ActiveWorkbook.BuiltinDocumentProperties("Creation Date")

You can do this with VBA
0
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34913791
Hi again,

Something like this code would
- open every xls, xlsx, xlsm file under C;\temp
- write the create date in A1 of the first sheet as a date format
- close and save the file

Pls change this line
    strFolderName = "c:\temp"
to set your directory

This line
With Wb.Sheets(1).[a1]
if you wanted to change a different cell
ie for B10 on second sheet
With Wb.Sheets(2).[b10]

Cheers

Dave


Sub Change()
'uses http://www.experts-exchange.com/A_2839.html
    Dim Wb As Workbook
    Dim strFName As String
    Dim strFolderName As String
    strFolderName = "c:\temp"

    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
    End With

    strFName = Dir(strFolderName & "\*.xls*")
    Do While Len(strFName) > 0
        Set Wb = Workbooks.Open(strFolderName & "\" & strFName)
        With Wb.Sheets(1).[a1]
            .NumberFormat = "dd-mmm-yyyy"
            .Value = Wb.BuiltinDocumentProperties("Creation Date")
        End With
        Wb.Save
        Wb.Close
        strFName = Dir
    Loop

    With Application
        .ScreenUpdating = True
        .DisplayAlerts = True
        .StatusBar = vbNullString
    End With

End Sub

Open in new window

0
 

Author Comment

by:spar-kle
ID: 34919868
Sorry for delay, it's been a busy day...

Thanks CaptainKenbo, though not quite what I was after, I'll keep the code for future reference..

brettdj, ..that's excellent, and thankyou for the added explanations
Only problem is that the date is incorrect, I'm sure there must be a simple fix
ie todays date comes out as 07-Aug-2001
Can you please help..
Thanks
Des
0
 

Author Closing Comment

by:spar-kle
ID: 34920251
Thanks brettdj
Really good!!!!
My problem was with the formatting in the original files.
If I can't work it out I'll post another question
Thanks for your help, excellent
Des
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

737 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