Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|