BeforeClose Dilemma

J

J. Cornor

hello everbody,
I have three workbooks;
WorkbookA, WorkbookB & WorkbookC (pseudonyms of course)
WorkbookA is the main project workbook.
WorkbookB serves as the Index workbook
that allows you to open one workbook
from a selection of a few hundred workbooks.
That one workbook becomes WorkbookC.
When WorkbookC opens, WorkbookB closes
leaving workbooks A & C open.
The user selects data to copy from
WorkbookC to WorkbookA by checking checkboxes
then a button attached to the procedure
that does the copy & paste routine.

When the user is done with "WorkbookC"
he must use the workbook's builtin "X" close button
to close the workbook.
I have a (Workbook_BeforeClose) procedure
in the ThisWorkbook code module.

1. It checks to see if any checkboxes are currently checked.
if not then it's ok to close out.
2. If it finds that there are checkboxes checked
it opens a userform located in an addin that alerts the user
he made a selection that would close the workbook
while some items remained checked
and it gives the user two choices:
1. copy the checked items to WorkbookA before closing, or
2. close the workbook without copying items.

if he chooses option 1
then it copies the data from bookA and pastes it in bookB.
if he chooses option 2
then bookC should just close without sending data to bookA.

Where the problem arises is;
I need both procedures to finish up by
closing WorkbookC when done and automatically
re-open WorkbookB.

I think it's the "Cancel=True" that's giving me headaches.

(Without it)
the bookC closes prematurely without finishing code.

(With it)
the bookC won't close at all

I'm hoping one of you gurus have an idea of what
my problem might be without me posting the code
because there's a bunch of it.

Of course if this can't be resolved without
viewing the code, we can go there. :)

Any suggestions would be so appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top