PDA

View Full Version : determine the last save



lior03
01-10-2006, 11:39 PM
hello
i want to determine the last time the activeworkbook was saved
is it:
Sub filesaved()
ActiveCell.Value = FileDateTime(ActiveWorkbook.Name)
End Sub
thanks

Ken Puls
01-11-2006, 12:16 AM
Hi moshe,

Nope. That gives you the last time opened, I believe. You'll want to go after one of the BuiltIn properties for last saved:

Sub filesaved()
ActiveCell.Value = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Sub

Look up the BuiltinDocumentProperties Property in the help to see what else you can grab from there. There's all kinds of good stuff.

HTH,

lior03
01-24-2008, 05:18 AM
hello
i want to make sure i do not save a workbook without changes being made.namely i want the workbook saved only after changes are made.

Select Case ActiveWorkbook.Saved
Case Is = True
MsgBox "workbook " & ActiveWorkbook.FullName & " is saved,no changes recorded", vbInformation _
, ActiveWorkbook.BuiltinDocumentProperties("last save time")
Case Is = False
MsgBox "workbook " & ActiveWorkbook.FullName & " contains unsaved changes...", vbInformation _
, ActiveWorkbook.BuiltinDocumentProperties("last save time")
ActiveWorkbook.Save
End Select


how can i tell if a workbook was changes

Bob Phillips
01-24-2008, 07:06 AM
Doesn't your code do just that by testing the workbook Saved property?

lior03
01-24-2008, 07:14 AM
i save my workbook.i activate the macro.it work as it should telling me no changes where made.i move to another cell activate the macro it tells me changes hade been made - and ask me to save the workbook.
how can the macro tell me changes took place while it did not enter any data.i just move to another cell.
thanks

lior03
01-28-2008, 03:21 AM
i want to spre myself the need to save workbook unnecessrilly.if i have several w.b open and none or some of them need not to be saved because no change occured ,how can i close them without the need to spent time saving...

Dim wbname As String
Dim wb As Workbook
Dim answer As Long
On Error Resume Next
wbname = ActiveWorkbook.name
For Each wb In Application.Workbooks
If wb.name <> wbname And Not wb.Saved = False Then
answer = MsgBox("Save changes for " & wb.name, vbYesNoCancel + vbExclamation, "close all inactive workbooks?")
Select Case answer
Case vbYes
wb.Close savechanges:=True
Case vbNo
Application.DisplayAlerts = False
wb.Close
Application.DisplayAlerts = True
Case vbCancel
Exit Sub
End Select
End If
Next wb