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.
Capture555.JPG
 
Upvote 0
Try this:
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
Dim wb  As Workbook

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
    Set wb = Workbooks.Open(Filename:=myPath & MyFile)
    With sh.Cells(i + 1, 2)
    .Value = wb.BuiltinDocumentProperties("Last Save Time")
    .NumberFormat = "mm-dd-yyyy h:mm AM/PM"

    
        End With
        wb.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

[CODE=vba]
[/CODE]
 
Upvote 0

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