excel vba withevents vbe

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel vba, withevents, vbe events

Excel vba, withevents, vbe events

resolvedResolved · Low Priority · Version 2010

C has attended:
No courses

Excel vba, withevents, vbe events

Hi,

I'm working with application events and want to control the following workflow:

1. When application starts, it creates xlApp WithEvents (in a class module)

Private WithEvents xlApp As Excel.Application

2. I want to stop the standard 'SaveAs' dialog showing but instead have created a Userform (as my new SaveAs). This is to be triggered with either the xlApp_WorkbookBeforeClose or xlApp_WorkbookBeforeSave procedures.

3. When calling it via the BeforeClose event and which triggers the Save event, I have chosen to set Cancel=True which stops the standard dialog and then I call my Userform - All OK so far.

4. But when I decide to click Cancel via the Userform (where I would like to close the workbook as unsaved), I'm still being prompted for the standard "Save, Don't Save and Cancel" prompt as it attempts to close the workbook again.

How do I stop this from showing again as the workbooks tries to close?

I added boolean flags to test and trap for this in order to force a close method using wb.Close False but this crashes the whole application.

The Cancel argument via the xlApp_WorkbookBeforeClose procedure is of no use as this just stops the close event being triggered altogether.

Some help would be ap[preciated please
csimms@fsmail.net

RE: excel vba, withevents, vbe events

Hi there

Thanks for your post which has been reviewed by one my colleagues. This is beyond the scope of this forum as we will really need to see your working files and spend some time testing potential solutions.

We term this as consultancy as specific resource and time needs to be committed with associated costs.

If you would like to discuss this further then please do reply to my email.

Kind regards

Jacob

Mon 12 Dec 2011: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Wrapping Text in a Cell in an Excel 2010 Workbook

When you have a lot of text you want to put in a particular cell but you can't decrease the font size to fit because the text will then become ineligible, then manually wrap the text in a cell by simply pressing ALT+ENTER.

View all Excel hints and tips


Server loaded in 0.1 secs.