Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
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
Medium Priority
?
281 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

647 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