![]() |
Show if file has been saved
I have a macro that saves a workbook (locally, and a second time to the
network shared file). Can I have two cells on the sheet that are (say) Red if the workbook has unsaved changes, and Green if it has been saved? Thanks RobL |
Show if file has been saved
The line of code you'd need to use is something like:
if thisworkbook.saved = true then 'it's saved else 'it's dirty (not saved end if But the bad news is where to put it. You can change lots of things that will make the workbook dirty, but not fire any event (like changing format, changing a print title, changing code, ...). But the very act of changing the format of the cell would make the workbook dirty. But you could cheat a little and ignore this. Kind of like this using a worksheet event: Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ThisWorkbook.Saved = True Then Me.Range("a1").Interior.ColorIndex = 3 ThisWorkbook.Saved = True Else Me.Range("a1").Interior.ColorIndex = 6 End If End Sub A couple of warnings -- most macros that do anything will destroy the Undo/Redo stack and clear the clipboard. Either of these are enough for me not to do this. I'd just add a macro that displayed the status: Option Explicit Sub testme() With ActiveWorkbook MsgBox .FullName & vbLf & "Saved: " & .Saved End With End Sub Put it in my personal.xl* file and assign it a shortcut key. Then run it when I wanted to know. Rob L wrote: I have a macro that saves a workbook (locally, and a second time to the network shared file). Can I have two cells on the sheet that are (say) Red if the workbook has unsaved changes, and Green if it has been saved? Thanks RobL -- Dave Peterson |
All times are GMT +1. The time now is 07:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com