Sensing altered workbook

dsimcox

Board Regular
Joined
Dec 8, 2004
Messages
75
Is there a way to determine if anything in a workbook has changed since it was opened?

I would like to use this information to run an On Close event before the workbook is closed - but only if the workbook has been altered.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Create a public variable, like
Public Changed as Boolean
and in the code for the ThisWorkbook object, do something like:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Changed = True
End Sub
In the BeforeClose event, test the value of Changed:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Changed then
'do your thing here
End If
End Sub
 
Upvote 0
If you Share the Workbook on a Network Server you can compare the current Server copy to the Active copy, for any changes:


Dim objSync As Office.Sync
Dim strStatus As String

Set objSync = ActiveDocument.Sync

If objSync.Status = msoSyncStatusConflict Then
strStatus = "The server copy has been changed." & vbCrLf & _
"Changes have been made by: " & _
objSync.WorkspaceLastChangedBy

MsgBox strStatus, vbInformation + vbOKOnly, "Server Copy Changed"
End If

Set objSync = Nothing
 
Upvote 0
Thank you gentlemen . . .

Your solution worked beautifully, Bob.

I'm going to experiment with Sharing thw workbook on our server - I've never dabbled with the .Sync method - I need to understand it, Joe.

Appreciate the expert help!
 
Upvote 0

Forum statistics

Threads
1,214,786
Messages
6,121,553
Members
449,038
Latest member
Guest1337

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