Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Before "Before Close" help needed!

Hi

Have a workbook that "before close" needs to export several of its sheets to
a new workbook, create a pivot table in that workbook, close and save the
new work book, then get on with closing itself. I have all the code to deal
with this and it works well by itself. However I also run the first workbook
from a set of buttons on the first sheet. One of these is an Exit button,
which saves and closes the workbook. I have also set the Before Close event
in the workbook to do the same thing, so that the user has to save and
close, which ever way they try to close the workbook.

My problem is that introducing the sub procedure in the "before close" event
to deal with the export. For some reason, it doesn't work. What is happening
in the "before close" event that is different from normal?

e.g. my sub needs to unhide 4 worksheets to in order to export them. This
does not happen when run from within the "before close" sub on the workbook.

Hope this all makes sense?

Joe

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Before "Before Close" help needed!

Hi Joe
you may paste your code currently used in this event procedure

--
Regards
Frank Kabel
Frankfurt, Germany


Joe 90 wrote:
Hi

Have a workbook that "before close" needs to export several of its
sheets to a new workbook, create a pivot table in that workbook,
close and save the new work book, then get on with closing itself. I
have all the code to deal with this and it works well by itself.
However I also run the first workbook from a set of buttons on the
first sheet. One of these is an Exit button, which saves and closes
the workbook. I have also set the Before Close event in the workbook
to do the same thing, so that the user has to save and close, which
ever way they try to close the workbook.

My problem is that introducing the sub procedure in the "before
close" event to deal with the export. For some reason, it doesn't
work. What is happening in the "before close" event that is different
from normal?

e.g. my sub needs to unhide 4 worksheets to in order to export them.
This does not happen when run from within the "before close" sub on
the workbook.

Hope this all makes sense?

JoeHi


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default Before "Before Close" help needed!

Suggestion is that you insert the statement "DoEvents" in
the sub procedure just after it unhides the worksheets;
or, alternatively, at the appropriate point in the
Before_Close event code.

Regards,
Greg
(VBA amateur)

-----Original Message-----
Hi

Have a workbook that "before close" needs to export

several of its sheets to
a new workbook, create a pivot table in that workbook,

close and save the
new work book, then get on with closing itself. I have

all the code to deal
with this and it works well by itself. However I also run

the first workbook
from a set of buttons on the first sheet. One of these is

an Exit button,
which saves and closes the workbook. I have also set the

Before Close event
in the workbook to do the same thing, so that the user

has to save and
close, which ever way they try to close the workbook.

My problem is that introducing the sub procedure in

the "before close" event
to deal with the export. For some reason, it doesn't

work. What is happening
in the "before close" event that is different from normal?

e.g. my sub needs to unhide 4 worksheets to in order to

export them. This
does not happen when run from within the "before close"

sub on the workbook.

Hope this all makes sense?

Joe

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Before "Before Close" help needed!

OK

Cracked the first part, and should have remembered this!

Using the EnabledEvents = False property in the click button event solves
the doubling up with the Before Close event.

I have also figured out how to set the BeforeClose Cancel argument to True
(Cancel =True) which means BeforeClose is bypassed.

Nevertheless, I now need to know how to stop the Yes/No/Cancel dialog
appearing from BeforeClose when called from another procedure(e.g.
Activeworkbook.Close) rather than giving me the dialog?
(Application.DisplayAlerts = False, doesn't seem to work in this instance?)

Cheers

Joe

"Joe 90" (remove silly spam) wrote in message
...
Hi

Have a workbook that "before close" needs to export several of its sheets to
a new workbook, create a pivot table in that workbook, close and save the
new work book, then get on with closing itself. I have all the code to deal
with this and it works well by itself. However I also run the first workbook
from a set of buttons on the first sheet. One of these is an Exit button,
which saves and closes the workbook. I have also set the Before Close event
in the workbook to do the same thing, so that the user has to save and
close, which ever way they try to close the workbook.

My problem is that introducing the sub procedure in the "before close" event
to deal with the export. For some reason, it doesn't work. What is happening
in the "before close" event that is different from normal?

e.g. my sub needs to unhide 4 worksheets to in order to export them. This
does not happen when run from within the "before close" sub on the workbook.

Hope this all makes sense?

Joe

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Disable "Save" &/or "Close" universal[_4_] Excel Programming 3 October 25th 03 12:38 PM
How can I get "File Close" to prompt me to "Save Changes" ?? Charles Jordan Excel Programming 4 July 31st 03 04:01 PM


All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"