Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default ++++++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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default ++++++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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default ++++++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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default ++++++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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"