Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ThisWorkbook.Saved does not work!

Hi
I have a workbook with 18 sheets and most of the VBA used
by the sheets is refereces to XLA files on the network.
Before the application is closed I want to inform the user
that the workbook is not saved if the user had forgotten
to save the workbook.

When I open the workbook the property ThisWorkbook.Saved =
True, but as soon as I close the Workbook (1 second after
opening) and catches the event Workbook_BeforeClose the
property have been set to False...why??? I do not have any
code in my project setting the property to False...does
anyone know what to do?

Best regards
/Niklas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default ThisWorkbook.Saved does not work!

Niklas,

from VBA help:
Saved Property =
True if no changes have been made to the specified
workbook since it was last saved. Read/write Boolean

Therefore, when you open your file and allow the links to
update, a change has been made which sets the Saved
property to False.

In other words, you should be checking for .saved=false if
you want to check the user hasn't forgotten.

Pete

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ThisWorkbook.Saved does not work!

Hi

I do not have any links. When I wrote refereces I meant
that I have used Tools-Referencess... in the editor. The
property Saved is True after I have opened my file. I
catch the event Workbook_BeforeClose after I have done
File-Close and in this event the Saved property is False.
What made the property to be False? I only did an "Close"!
Best regards
/Niklas

My question is: how can the workbook

-----Original Message-----
Niklas,

from VBA help:
Saved Property =
True if no changes have been made to the specified
workbook since it was last saved. Read/write Boolean

Therefore, when you open your file and allow the links to
update, a change has been made which sets the Saved
property to False.

In other words, you should be checking for .saved=false

if
you want to check the user hasn't forgotten.

Pete

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default ThisWorkbook.Saved does not work!

There are other ways this can occur, such as with Volatile formulas that
recalculate frequently:

XL: "Save Changes in <Bookname" Prompt Even If No Changes Are Made
http://support.microsoft.com/default...b;EN-US;274500

So if you have volatile formulas, the saved property will be false
immediately after opening because of recalculation, even if you don't touch
the workbook.


"Niklas" wrote in message
...
Hi

I do not have any links. When I wrote refereces I meant
that I have used Tools-Referencess... in the editor. The
property Saved is True after I have opened my file. I
catch the event Workbook_BeforeClose after I have done
File-Close and in this event the Saved property is False.
What made the property to be False? I only did an "Close"!
Best regards
/Niklas

My question is: how can the workbook

-----Original Message-----
Niklas,

from VBA help:
Saved Property =
True if no changes have been made to the specified
workbook since it was last saved. Read/write Boolean

Therefore, when you open your file and allow the links to
update, a change has been made which sets the Saved
property to False.

In other words, you should be checking for .saved=false

if
you want to check the user hasn't forgotten.

Pete

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default ThisWorkbook.Saved does not work!

Niklas:

A button display Thisbook.Saved = True immediatly after I open the

workbook

...and as soon as this occurs, the Saved property is set to False because you
have made a change to the Workbook.

the only thing I have done is File-Exit


Not true. You also set a button caption.

The following code demonstrates the sequence:

Private Sub Workbook_Open()

Sheets(1).Range("A1") = ThisWorkbook.Saved
Sheets(1).Range("A2") = ThisWorkbook.Saved
ThisWorkbook.Saved = True

' 1st line returns TRUE: no changes have been made yet (just like your
button).

' 2nd line returns FALSE: the first line made a change by writing a
value to a cell.
' Setting a button caption would have the same effect.

' POSSIBLE REMEDY:
'3rd line "cancels" the effect of the previous changes on the Saved
property, but does not cancel the actual changes.

' So, if you exit the workbook now, you will not get the "Save
Changes?" prompt,
' *but* the changes made by lines 1 & 2 will not have been saved.
However, as long as those changes were
' generated by code in your Opening routines, this is probably
acceptable. This is why the property is Read/Write instead of Read Only.

End Sub


Hope this helps,

--
George Nicholson

Remove 'Junk' from return address.



"Niklas" wrote in message
...
Thank you, that solved another problem of mine, but not
this one. A button display Thisbook.Saved = True
immediatly after I open the workbook, but when I catch the
event Workbook_BeforeClose the property Thisbook.Saved =
FAlse and the only thing I have done is File-Exit....
Bets regards
/Niklas

-----Original Message-----
There are other ways this can occur, such as with

Volatile formulas that
recalculate frequently:

XL: "Save Changes in <Bookname" Prompt Even If No

Changes Are Made
http://support.microsoft.com/default.aspx?scid=kb;EN-

US;274500

So if you have volatile formulas, the saved property will

be false
immediately after opening because of recalculation, even

if you don't touch
the workbook.


"Niklas" wrote in message
...
Hi

I do not have any links. When I wrote refereces I meant
that I have used Tools-Referencess... in the editor.

The
property Saved is True after I have opened my file. I
catch the event Workbook_BeforeClose after I have done
File-Close and in this event the Saved property is

False.
What made the property to be False? I only did

an "Close"!
Best regards
/Niklas

My question is: how can the workbook

-----Original Message-----
Niklas,

from VBA help:
Saved Property =
True if no changes have been made to the specified
workbook since it was last saved. Read/write Boolean

Therefore, when you open your file and allow the links

to
update, a change has been made which sets the Saved
property to False.

In other words, you should be checking for .saved=false
if
you want to check the user hasn't forgotten.

Pete

.



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default ThisWorkbook.Saved does not work!

Hi
I'm sorry that I was not clear enought. The button only
executed "msgbox Thisbook.Saved" so I did not change any
Caption. The only thing I do is File-Exit...and the
moment before the property Thisbook.Saved was True.
I have found a Workaround and that is that I execute the
line "ThisWorkbook.Save" in the event Workbook_Open(), but
I do not like this type of workaround coding!
Best regards
/Niklas

-----Original Message-----
Niklas:

A button display Thisbook.Saved = True immediatly

after I open the
workbook

...and as soon as this occurs, the Saved property is set

to False because you
have made a change to the Workbook.

the only thing I have done is File-Exit


Not true. You also set a button caption.

The following code demonstrates the sequence:

Private Sub Workbook_Open()

Sheets(1).Range("A1") = ThisWorkbook.Saved
Sheets(1).Range("A2") = ThisWorkbook.Saved
ThisWorkbook.Saved = True

' 1st line returns TRUE: no changes have been made

yet (just like your
button).

' 2nd line returns FALSE: the first line made a

change by writing a
value to a cell.
' Setting a button caption would have the same

effect.

' POSSIBLE REMEDY:
'3rd line "cancels" the effect of the previous

changes on the Saved
property, but does not cancel the actual changes.

' So, if you exit the workbook now, you will not get

the "Save
Changes?" prompt,
' *but* the changes made by lines 1 & 2 will not

have been saved.
However, as long as those changes were
' generated by code in your Opening routines, this

is probably
acceptable. This is why the property is Read/Write

instead of Read Only.

End Sub


Hope this helps,

--
George Nicholson

Remove 'Junk' from return address.



"Niklas" wrote in message
...
Thank you, that solved another problem of mine, but not
this one. A button display Thisbook.Saved = True
immediatly after I open the workbook, but when I catch

the
event Workbook_BeforeClose the property Thisbook.Saved =
FAlse and the only thing I have done is File-Exit....
Bets regards
/Niklas

-----Original Message-----
There are other ways this can occur, such as with

Volatile formulas that
recalculate frequently:

XL: "Save Changes in <Bookname" Prompt Even If No

Changes Are Made
http://support.microsoft.com/default.aspx?scid=kb;EN-

US;274500

So if you have volatile formulas, the saved property

will
be false
immediately after opening because of recalculation,

even
if you don't touch
the workbook.


"Niklas" wrote in message
...
Hi

I do not have any links. When I wrote refereces I

meant
that I have used Tools-Referencess... in the editor.

The
property Saved is True after I have opened my file. I
catch the event Workbook_BeforeClose after I have

done
File-Close and in this event the Saved property is

False.
What made the property to be False? I only did

an "Close"!
Best regards
/Niklas

My question is: how can the workbook

-----Original Message-----
Niklas,

from VBA help:
Saved Property =
True if no changes have been made to the specified
workbook since it was last saved. Read/write Boolean

Therefore, when you open your file and allow the

links
to
update, a change has been made which sets the Saved
property to False.

In other words, you should be checking

for .saved=false
if
you want to check the user hasn't forgotten.

Pete

.



.



.

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
lost work that wasn't saved. Can I retrieve it? How? Beverly 1031 investor, Florida Excel Discussion (Misc queries) 0 March 8th 07 09:03 PM
IF / VLOOKUP formula won't work until saved tawtrey(remove this )@pacificfoods.com Excel Worksheet Functions 2 August 4th 05 11:55 PM
Can not work with saved files Totallylost Excel Discussion (Misc queries) 3 February 23rd 05 09:49 PM
How to get saved old saved work that was saved over? Maral Excel Discussion (Misc queries) 1 February 20th 05 08:59 PM
VB controls don't work in web saved Excel workbook Mike Murschel[_2_] Excel Programming 0 October 14th 03 06:41 PM


All times are GMT +1. The time now is 12:40 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"