Date and Time not showing

Fathermole

New Member
Joined
Nov 17, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
have this code but when it runs date and time do not Show
VBA Code:
Sub list_save_times()

Dim myPath As String
Dim MyFile As String
Dim FldrPPicker As FileDialog
Dim sh As Worksheet
Dim i As Integer

Application.ScreenUpdating = False

Set sh = ThisWorkbook.Sheets("Last Save Times")
Set FldrPicker = Application.FileDialog(msoFileDialogFolderPicker)

    With FldrPicker
        .Title = "Please Select Folder"
        .AllowMultiSelect = False
        .ButtonName = "Confirm!!!"
        If .Show = -1 Then
            myPath = .SelectedItems(1) & "\"
        Else
            End
        End If
    End With

sh.Activate
sh.Cells.ClearContents
Cells(1, 1) = "File Name(s)"
Cells(1, 2) = "Last Time Saved"
Cells(1, 4) = "Location:"
Cells(1, 5) = myPath
    
    
MyFile = Dir(myPath)
i = 1

Do While MyFile <> ""

    sh.Cells(i + 1, 1) = MyFile
    Workbooks.Open Filename:=myPath & MyFile
    With sh.Cells(i + 1, 2)
    .Value = ActiveWorkbook.BuiltinDocumentProperties(4)
    .NumberFormat = "mm-dd-yyyy h:mm AM/PM"

    
        End With
        ActiveWorkbook.Close savechanges:=False
        
    MyFile = Dir
    i = i + 1
Loop
sh.Range("A:B").Columns.AutoFit

If i = 1 Then
    
        
        MsgBox "There are no items in this folder"
         End If
        Application.ScreenUpdating = True
   
        
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
VBA Code:
.Value = ActiveWorkbook.BuiltinDocumentProperties(4)

Because the above is returning an empty value. The Item(4) property is not a date. To display a date, you have to choose a property that is a date.

 
Upvote 0
It Gets the Files just not the save times
1700276682458.png
 
Upvote 0
@faterhmore, @rlv01 if referring to your comment
date and time do not Show
which in your code is represented by
VBA Code:
    With sh.Cells(i + 1, 2)
    .Value = ActiveWorkbook.BuiltinDocumentProperties(4)

and trying to point out that 4 does not represent the item number for date last saved.

You need to be using either of these 2,
VBA Code:
ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
ActiveWorkbook.BuiltinDocumentProperties(12)

You can find the complete list on the BetterSolutions site here:

I couldn't find any enumeration for Excel as there is for word. The word item number for most of them are the same and can be found here.
 
Last edited:
Upvote 0
MsoDocProperties is the enumeration type.

NameValueDescription
msoPropertyTypeBoolean2Boolean value.
msoPropertyTypeDate3Date value.
msoPropertyTypeFloat5Floating point value.
msoPropertyTypeNumber1Integer value.
msoPropertyTypeString4String value.


 
Upvote 0
MsoDocProperties is the enumeration type.

NameValueDescription
msoPropertyTypeBoolean2Boolean value.
msoPropertyTypeDate3Date value.
msoPropertyTypeFloat5Floating point value.
msoPropertyTypeNumber1Integer value.
msoPropertyTypeString4String value.


That is very short list and doesn't include one for Last Save Time.
 
Upvote 0
That is very short list and doesn't include one for Last Save Time.

Because it is a list of the property type enumerations, not the property names. A list of the property names would be longer.
ItemProperty NamesTypeType Enumeration
1Title4msoPropertyTypeString
2Subject4msoPropertyTypeString
3Author4msoPropertyTypeString
4Keywords4msoPropertyTypeString
5Comments4msoPropertyTypeString
6Template4msoPropertyTypeString
7Last author4msoPropertyTypeString
8Revision number4msoPropertyTypeString
9Application name4msoPropertyTypeString
10Last print date3msoPropertyTypeDate
11Creation date3msoPropertyTypeDate
12Last save time3msoPropertyTypeDate
13Total editing time1msoPropertyTypeNumber
14Number of pages1msoPropertyTypeNumber
15Number of words1msoPropertyTypeNumber
16Number of characters1msoPropertyTypeNumber
17Security1msoPropertyTypeNumber
18Category4msoPropertyTypeString
19Format4msoPropertyTypeString
20Manager4msoPropertyTypeString
21Company4msoPropertyTypeString
22Number of bytes1msoPropertyTypeNumber
23Number of lines1msoPropertyTypeNumber
24Number of paragraphs1msoPropertyTypeNumber
25Number of slides1msoPropertyTypeNumber
26Number of notes1msoPropertyTypeNumber
27Number of hidden Slides1msoPropertyTypeNumber
28Number of multimedia clips1msoPropertyTypeNumber
29Hyperlink base4msoPropertyTypeString
30Number of characters (with spaces)1msoPropertyTypeNumber
31Content type4msoPropertyTypeString
32Content status4msoPropertyTypeString
33Language4msoPropertyTypeString
34Document version4msoPropertyTypeString
 
Upvote 0
This worked for me. Won't work on a Workbook that hasn't been saved yet (obviously)
VBA Code:
d = ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top