Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default 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/



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/





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



.

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



.

.

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
Workbook_BeforeClose Ed Davis[_2_] Excel Discussion (Misc queries) 21 September 26th 09 01:01 AM
Workbook_BeforeClose Event Shatin Excel Programming 2 January 24th 04 03:50 AM
File won't close when "beforeclose" event is used. David G[_3_] Excel Programming 4 December 8th 03 04:22 AM
Cancelling the BeforeClose Event Troy[_5_] Excel Programming 6 December 2nd 03 06:40 AM
BeforeClose event - Savings Mike[_40_] Excel Programming 3 September 24th 03 11:33 AM


All times are GMT +1. The time now is 10:52 AM.

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"