ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_Beforeclose vs BeforeClose Event (https://www.excelbanter.com/excel-programming/289897-re-workbook_beforeclose-vs-beforeclose-event.html)

Juan Pablo González

Workbook_Beforeclose vs BeforeClose Event
 
Maybe this works for you ?

http://j-walk.com/ss/excel/tips/tip78.htm

--
Regards,

Juan Pablo González

"jasonsweeney " wrote in
message ...
I am trying to run some code rightbefore a workbook closes. The code
relates to resetting some passwords hidden in a worksheet.

What I want is the code to execute after a person tries to close the
workbook.

Right now I am using the "BeforeClose" event. The problem here is that
the code executes, and then Excel asks the user whether they want to
save changes made to the worksheet before closing. If the person says
no, then my the effect of my password codes does not take effect.

I want to use the Workbook_BeforeClose event, which I think is the last
event before the workbook closes, which would allow me to get my
desired effect without allowing the user to "veto" the cnages I make to
their worksheet right before it closes.

However, nothing happens when I use the event. I think this is because
I have to "create a new class module and declare an object of type
Application with events." (VBA Help for WorkbookBeforeClose Event". I
have noever done this before.

Any suggestions?


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Workbook_Beforeclose vs BeforeClose Event
 
That may give you some ideas, but it seem to me, if you make changes, you
want them saved. Therefore in the BeforeClose events, turn off Events, save
the workbook, then turn events back on.

--
Regards,
Tom Ogilvy

Juan Pablo González wrote in message
...
Maybe this works for you ?

http://j-walk.com/ss/excel/tips/tip78.htm

--
Regards,

Juan Pablo González

"jasonsweeney " wrote in
message ...
I am trying to run some code rightbefore a workbook closes. The code
relates to resetting some passwords hidden in a worksheet.

What I want is the code to execute after a person tries to close the
workbook.

Right now I am using the "BeforeClose" event. The problem here is that
the code executes, and then Excel asks the user whether they want to
save changes made to the worksheet before closing. If the person says
no, then my the effect of my password codes does not take effect.

I want to use the Workbook_BeforeClose event, which I think is the last
event before the workbook closes, which would allow me to get my
desired effect without allowing the user to "veto" the cnages I make to
their worksheet right before it closes.

However, nothing happens when I use the event. I think this is because
I have to "create a new class module and declare an object of type
Application with events." (VBA Help for WorkbookBeforeClose Event". I
have noever done this before.

Any suggestions?


---
Message posted from http://www.ExcelForum.com/






eric

Workbook_Beforeclose vs BeforeClose Event
 
Try placing your code in the Workbook.deactivate event
that should do it.
-----Original Message-----
Maybe this works for you ?

http://j-walk.com/ss/excel/tips/tip78.htm

--
Regards,

Juan Pablo González

"jasonsweeney " <<jasonsweeney.10yqwl@excelforum-

nospam.com wrote in
message ...
I am trying to run some code rightbefore a workbook

closes. The code
relates to resetting some passwords hidden in a

worksheet.

What I want is the code to execute after a person tries

to close the
workbook.

Right now I am using the "BeforeClose" event. The

problem here is that
the code executes, and then Excel asks the user whether

they want to
save changes made to the worksheet before closing. If

the person says
no, then my the effect of my password codes does not

take effect.

I want to use the Workbook_BeforeClose event, which I

think is the last
event before the workbook closes, which would allow me

to get my
desired effect without allowing the user to "veto" the

cnages I make to
their worksheet right before it closes.

However, nothing happens when I use the event. I think

this is because
I have to "create a new class module and declare an

object of type
Application with events." (VBA Help for

WorkbookBeforeClose Event". I
have noever done this before.

Any suggestions?


---
Message posted from http://www.ExcelForum.com/



.


eric

Workbook_Beforeclose vs BeforeClose Event
 
I was wrong, I tested it and it does not seem to work
there.
-----Original Message-----
Try placing your code in the Workbook.deactivate event
that should do it.
-----Original Message-----
Maybe this works for you ?

http://j-walk.com/ss/excel/tips/tip78.htm

--
Regards,

Juan Pablo González

"jasonsweeney " <<jasonsweeney.10yqwl@excelforum-

nospam.com wrote in
message ...
I am trying to run some code rightbefore a workbook

closes. The code
relates to resetting some passwords hidden in a

worksheet.

What I want is the code to execute after a person

tries
to close the
workbook.

Right now I am using the "BeforeClose" event. The

problem here is that
the code executes, and then Excel asks the user

whether
they want to
save changes made to the worksheet before closing. If

the person says
no, then my the effect of my password codes does not

take effect.

I want to use the Workbook_BeforeClose event, which I

think is the last
event before the workbook closes, which would allow me

to get my
desired effect without allowing the user to "veto" the

cnages I make to
their worksheet right before it closes.

However, nothing happens when I use the event. I

think
this is because
I have to "create a new class module and declare an

object of type
Application with events." (VBA Help for

WorkbookBeforeClose Event". I
have noever done this before.

Any suggestions?


---
Message posted from http://www.ExcelForum.com/



.

.



All times are GMT +1. The time now is 01:47 PM.

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