ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ++++++PLEASE HELP++++++ (https://www.excelbanter.com/excel-programming/320907-please-help.html)

Chris

++++++PLEASE HELP++++++
 
Is there a way to use visual basic to only save a workbook when changes have
been made to it?

I have a large spreadsheet with a VB front end on it, every time I exit it
saves. Even if changes have not been made. I want to avoid this as it takes a
long time to save.

Please help, I cant find out how to do it anywhere.

KL

++++++PLEASE HELP++++++
 
Chris,

Have you tried putting the followig code into ThisWorkbook module?

Regards,
KL

'----------Code Start-----------
Public WBChanged As Boolean

Private Sub Workbook_Open()
WBChanged = False
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
WBChanged = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If WBChanged = True Then
Me.Save
Else
Me.Saved = True
End If
End Sub

'----------Code End-----------


"Chris" wrote in message
...
Is there a way to use visual basic to only save a workbook when changes
have
been made to it?

I have a large spreadsheet with a VB front end on it, every time I exit it
saves. Even if changes have not been made. I want to avoid this as it
takes a
long time to save.

Please help, I cant find out how to do it anywhere.




Chris

++++++PLEASE HELP++++++
 
This seams to have worked.

Thanks

"KL" wrote:

Chris,

Have you tried putting the followig code into ThisWorkbook module?

Regards,
KL

'----------Code Start-----------
Public WBChanged As Boolean

Private Sub Workbook_Open()
WBChanged = False
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
WBChanged = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If WBChanged = True Then
Me.Save
Else
Me.Saved = True
End If
End Sub

'----------Code End-----------


"Chris" wrote in message
...
Is there a way to use visual basic to only save a workbook when changes
have
been made to it?

I have a large spreadsheet with a VB front end on it, every time I exit it
saves. Even if changes have not been made. I want to avoid this as it
takes a
long time to save.

Please help, I cant find out how to do it anywhere.





Vic Eldridge[_3_]

++++++PLEASE HELP++++++
 
Hi Chris,

Look at the Saved property of the Workbook object to see if any changes have
been made.

Regards,
Vic Eldridge


"Chris" wrote:

Is there a way to use visual basic to only save a workbook when changes have
been made to it?

I have a large spreadsheet with a VB front end on it, every time I exit it
saves. Even if changes have not been made. I want to avoid this as it takes a
long time to save.

Please help, I cant find out how to do it anywhere.



All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com