ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ActiveWorkbook.Save DOESNT WORK !! (https://www.excelbanter.com/excel-programming/335273-activeworkbook-save-doesnt-work.html)

slintz

ActiveWorkbook.Save DOESNT WORK !!
 
Any ideas why a workbook Save method would fail to actually save without
raising any errors? Just after, the "Saved" property remains FALSE (at least
that much makes sense) - but I have no ideas what to look for / verify.

TIA!

Norman Jones

ActiveWorkbook.Save DOESNT WORK !!
 
Hi Slintz,

In the VBE, select the workbook's ThisWorkbbook module and look for a
Workbook_BeforeSave code something like:


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel
As Boolean)
'possible code lines

Cancel = True <<==== LOOK FOR THIS

'possible additional cde

End Sub

The marked line, as might intuitively be expected, cancels any save
operation,

---
Regards,
Norman



"slintz" wrote in message
...
Any ideas why a workbook Save method would fail to actually save without
raising any errors? Just after, the "Saved" property remains FALSE (at
least
that much makes sense) - but I have no ideas what to look for / verify.

TIA!




Norman Jones

ActiveWorkbook.Save DOESNT WORK !!
 
Hi Slintz.

Without knowing, what you are doing, possibly, hopefully, I am wrong but...

Wording like:

then un-twiddling and forcing the Saved property to TRUE


causes a nagging concern.

If you set the Saved property to true, the workbook will not save, because
the Excel accepts believes the Save to have been effected already.

As I said, I may well be wrong but, especially in the light of your
experience, the Save operation and setting Save =True do not immediately
strike me as likely bedfellows.

Just a thought...

---
Regards,
Norman



"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the Saved
property to TRUE). My event sub dutifully dis-ables events before the
doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...
THANX!




slintz

ActiveWorkbook.Save DOESNT WORK !!
 
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the Saved
property to TRUE). My event sub dutifully dis-ables events before the doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at... THANX!

Anne Troy[_2_]

ActiveWorkbook.Save DOESNT WORK !!
 
And my first thought, tho I'm not a *real* coder, was ... are you disabliing
events? I don't think you should be.
*******************
~Anne Troy

www.OfficeArticles.com


"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the Saved
property to TRUE). My event sub dutifully dis-ables events before the

doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...

THANX!



Tom Ogilvy

ActiveWorkbook.Save DOESNT WORK !!
 
If the OP is doing a SAVE within the BeforeSave Event as he seems to
indicate, then you certainly should disable events. unless you want to have
recursive events occuring.

--
Regards,
Tom Ogilvy


"Anne Troy" wrote in message
...
And my first thought, tho I'm not a *real* coder, was ... are you

disabliing
events? I don't think you should be.
*******************
~Anne Troy

www.OfficeArticles.com


"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within

Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the

Saved
property to TRUE). My event sub dutifully dis-ables events before the

doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...

THANX!





Norman Jones

ActiveWorkbook.Save DOESNT WORK !!
 
Apologies for my clock glitch.

Trying to change regional settings and (mistakenly) believing that I can,
successfully, perform multiple tasks simultaneously.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Slintz.

Without knowing, what you are doing, possibly, hopefully, I am wrong
but...

Wording like:

then un-twiddling and forcing the Saved property to TRUE


causes a nagging concern.

If you set the Saved property to true, the workbook will not save, because
the Excel accepts believes the Save to have been effected already.

As I said, I may well be wrong but, especially in the light of your
experience, the Save operation and setting Save =True do not immediately
strike me as likely bedfellows.

Just a thought...

---
Regards,
Norman



"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within
Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the
Saved
property to TRUE). My event sub dutifully dis-ables events before the
doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...
THANX!






Tom Ogilvy

ActiveWorkbook.Save DOESNT WORK !!
 
Let's say I want to hide sheets, save the workbook, unhide sheets as a form
of security - to prevent the workbook being saved with the sheets unhidden.
this will all be done in the beforesave. Since his code explicitly saves
the workbook before setting the Saved property, there should be no reason it
wouldn't work in doing the initial save. However, the Cancel property
should be set to true to prevent the initiating save action. I don't
believe setting the Saved property prevents saving - it prevent the prompt
to save.

--
Regards,
tom Ogilvy



"Norman Jones" wrote in message
...
Apologies for my clock glitch.

Trying to change regional settings and (mistakenly) believing that I can,
successfully, perform multiple tasks simultaneously.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Slintz.

Without knowing, what you are doing, possibly, hopefully, I am wrong
but...

Wording like:

then un-twiddling and forcing the Saved property to TRUE


causes a nagging concern.

If you set the Saved property to true, the workbook will not save,

because
the Excel accepts believes the Save to have been effected already.

As I said, I may well be wrong but, especially in the light of your
experience, the Save operation and setting Save =True do not immediately
strike me as likely bedfellows.

Just a thought...

---
Regards,
Norman



"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within
Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle some
stuffs just before saving, saving, then un-twiddling and forcing the
Saved
property to TRUE). My event sub dutifully dis-ables events before the
doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...
THANX!








Norman Jones

ActiveWorkbook.Save DOESNT WORK !!
 
Hi Tom ,

I totally agree with your comments.

I guess that my, admittedly speculative, concern related to a possible
scenario like:

Me.Saved = True
Me Close

However, looking again at the OP's initial post I see:

Just after, the "Saved" property remains FALSE


Which puts my speculation where it deserves to go.

The speculation was fuelled by the fact that, except for the Cancel = True
(my first guess) I have never seen a workbook evince the signs of saving
and yet quietly not do so.

Thank you and apologies for the delay in reponding.


---
Regards,
Norman


"Tom Ogilvy" wrote in message
...
Let's say I want to hide sheets, save the workbook, unhide sheets as a
form
of security - to prevent the workbook being saved with the sheets
unhidden.
this will all be done in the beforesave. Since his code explicitly saves
the workbook before setting the Saved property, there should be no reason
it
wouldn't work in doing the initial save. However, the Cancel property
should be set to true to prevent the initiating save action. I don't
believe setting the Saved property prevents saving - it prevent the prompt
to save.

--
Regards,
tom Ogilvy



"Norman Jones" wrote in message
...
Apologies for my clock glitch.

Trying to change regional settings and (mistakenly) believing that I can,
successfully, perform multiple tasks simultaneously.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Slintz.

Without knowing, what you are doing, possibly, hopefully, I am wrong
but...

Wording like:

then un-twiddling and forcing the Saved property to TRUE

causes a nagging concern.

If you set the Saved property to true, the workbook will not save,

because
the Excel accepts believes the Save to have been effected already.

As I said, I may well be wrong but, especially in the light of your
experience, the Save operation and setting Save =True do not
immediately
strike me as likely bedfellows.

Just a thought...

---
Regards,
Norman



"slintz" wrote in message
...
Good idea AND still not working... <grrr

In fact, the Save method is being fired from within
Workbook_BeforeSave(),
which needs to do some preparations for the next open (ie. twiddle
some
stuffs just before saving, saving, then un-twiddling and forcing the
Saved
property to TRUE). My event sub dutifully dis-ables events before the
doing
the problem Save, then re-ables events afterwards.

Still, this is a very good lead that I will look more closely at...
THANX!










All times are GMT +1. The time now is 03:37 AM.

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