I've never found a satisfactory way around this. I tend to insert calls to
the routine that creates the xlApp object in a lot of places, so the object
is assured of being around "most of the time". Then I also put a button that
explicitly recreates the object somewhere in the menu.
Generally this is less of a problem when my users are using the programs
than when I am, since they don't go messing about in the VB Editor, and they
don't go crashing lots of things. (My development environment is a mess.)
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______
"Adrian Johnson, CA" <Adrian Johnson,
(E-Mail Removed)> wrote in
message news:6BD48058-4404-49EC-A542-(E-Mail Removed)...
> I've been working on a similar procedure, and have used the method
> suggested
> by Chip below.
>
> I created a class and include the declaration in that class:
> 'Public WithEvents xlapp As Application'
>
> I then create an instance of that class when ThisWorkbook is opened - the
> technique Chip outlines on his very useful website.
>
> It all works fine, unless I click on the stop button in the VBA editor, or
> something similar, which destroys the object set up to capture the
> application events.
>
> Is there anyway around this?
>
> Thanks.
>
> Adrian.
>
> "Chip Pearson" wrote:
>
>> One way would be the capture the BeforeSave event, test the SaveAsUI
>> parameter and if true, set Cancel to True and put up your own dialog.
>>
>>
>> --
>> Cordially,
>> Chip Pearson
>> Microsoft MVP - Excel
>> Pearson Software Consulting LLC
>> www.cpearson.com
>> (email on the web site)
>>
>> "Aruna Akella" <(E-Mail Removed)> wrote in message
>> news:9EDCC992-A042-47A8-BBA6-(E-Mail Removed)...
>> > My application is addin to Excel. I am trying to capture Excel Save and
>> > Cancel buttons on Save As dialog box - so that I can call methods
>> > relevant
>> > to
>> > my app depending on what user pressed. Is there a way to capture those
>> > events?
>> >
>> > Thanks in advance!
>> >
>> > --
>> > Aruna
>>
>>
>>