how can I save a workbook only if it has been modified? 
Author Message
 how can I save a workbook only if it has been modified?

What vba procedure is required to only save a file if it has been
changed/edited.
I'm writing an application which saves and quits the application
but the workbooks need saving in a predetermined order to prevent
referencing errors and dont want to change the modified date tag of
workbooks which havent been modified.

thanks

raj

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 how can I save a workbook only if it has been modified?
Try

if not activeworkbook.Saved then
'save your workbooks here in order
end if

Ken Valenti

Quote:

> What vba procedure is required to only save a file if it has been
> changed/edited.
> I'm writing an application which saves and quits the application
> but the workbooks need saving in a predetermined order to prevent
> referencing errors and dont want to change the modified date tag of
> workbooks which havent been modified.

> thanks

> raj

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 how can I save a workbook only if it has been modified?
thanks for your reply, but i think my situation is made slightly more
difficult, because i've got three workbooks which need saving and the
operation can happen from any workbook, but the order of saving must be
the same. I've used your suggestion and also used workbook
("a").activate then used activeworkbook.saved for each book, but the
command always shows FALSE and so it always does a save!

raj

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 how can I save a workbook only if it has been modified?
I forgot to trap the error if Book1.xls is not open

On Error Resume Next
Workbooks("Book1.xls").Close savechanges:=True
On Error GoTo 0

Ken



Wed, 18 Jun 1902 08:00:00 GMT  
 how can I save a workbook only if it has been modified?
I'm not sure what to do about the Saved property.  Try this

Private Sub Workbook_Open()
ThisWorkbook.Saved = True
End Sub

Here are some more ideas:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each Workbook In Workbooks
Select Case Workbook.Name
Case Is = ThisWorkbook.Name, "TempTest2.xls"
If Not Workbook.Saved Then GoTo SaveAll
Case Else
'ignore if not
End Select
Next
Application.EnableEvents = False 'if you have before save / close code in
others
On Error Resume Next 'in case TempTest2.xls is not open
Workbooks("TempTest2.xls").Close ' savechanges:=false  - there should be no
changes, but..
On Error GoTo 0
Application.EnableEvents = True
Exit Sub
SaveAll:
Application.EnableEvents = False 'if you have before save / close code in
others
Workbooks("Book1.xls").Close savechanges:=True
ThisWorkbook.Save
Application.EnableEvents = True
MsgBox ("Saved")
End Sub

Ken Valenti

Quote:

> thanks for your reply, but i think my situation is made slightly more
> difficult, because i've got three workbooks which need saving and the
> operation can happen from any workbook, but the order of saving must be
> the same. I've used your suggestion and also used workbook
> ("a").activate then used activeworkbook.saved for each book, but the
> command always shows FALSE and so it always does a save!

> raj

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. I am having Problems modifying the pull downs in the samples Orders (entry) form

2. I am having problems saving documents

3. No prompt to save modified workbook when manually closing

4. Referencing to cells in a workbook without having the workbook activated

5. Message stating the workbook is lock, not protected, I am the creator of this workbook

6. Getting data from multiple workbooks WITHOUT having all the other workbooks open

7. Excel97 Opening workbook macro when the workbook is password protected for modifying

8. Macro to open a workbook, work in that workbook, than close the workbook (saved)

9. Having trouble sending email?....so am I

10. I am having a problem with Outlook 98


 
Powered by phpBB® Forum Software © phpBB Group