Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application Event Scope Problem

I have an Add-In where I have created a class which holds a couple of
application level events. In the class I declare a public Application
object WithEvents. The class is instantiated in the Add-In
WorkBook_Open event. When I load a workbook with the Add-In attached
the events seem to fire ok on the workbook, it being the active
workbook. However, I have a form on the Add-In activated from a toolbar
button which is periodically displayed during a program loop for the
user to make a choice. On the form I have a button which stops the
program with the End keyword if the user wants to stop the program.
When this button is pressed the code stops running ok but so do the
application events.

Any help appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Application Event Scope Problem

The End keyword should never be used. It completely terminates
all VBA code and reset all public variables to their default
values. You should instead use Exit Sub or Exit Function to exit
from the called procedure, perhaps returning a value indicating
to the calling procedure that it, too, should call Exit Sub.

In short, design your code so that End is never used.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com








wrote in message
oups.com...
I have an Add-In where I have created a class which holds a
couple of
application level events. In the class I declare a public
Application
object WithEvents. The class is instantiated in the Add-In
WorkBook_Open event. When I load a workbook with the Add-In
attached
the events seem to fire ok on the workbook, it being the active
workbook. However, I have a form on the Add-In activated from a
toolbar
button which is periodically displayed during a program loop
for the
user to make a choice. On the form I have a button which stops
the
program with the End keyword if the user wants to stop the
program.
When this button is pressed the code stops running ok but so do
the
application events.

Any help appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application Event Scope Problem

Thanks

Mike
Chip Pearson wrote:
The End keyword should never be used. It completely terminates
all VBA code and reset all public variables to their default
values. You should instead use Exit Sub or Exit Function to exit
from the called procedure, perhaps returning a value indicating
to the calling procedure that it, too, should call Exit Sub.

In short, design your code so that End is never used.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com








wrote in message
oups.com...
I have an Add-In where I have created a class which holds a
couple of
application level events. In the class I declare a public
Application
object WithEvents. The class is instantiated in the Add-In
WorkBook_Open event. When I load a workbook with the Add-In
attached
the events seem to fire ok on the workbook, it being the active
workbook. However, I have a form on the Add-In activated from a
toolbar
button which is periodically displayed during a program loop
for the
user to make a choice. On the form I have a button which stops
the
program with the End keyword if the user wants to stop the
program.
When this button is pressed the code stops running ok but so do
the
application events.

Any help appreciated.


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
Launch Click Event Using Application.Run cellist Excel Discussion (Misc queries) 4 November 5th 09 12:46 AM
Application level event help John Bundy Excel Discussion (Misc queries) 2 January 15th 08 10:30 PM
Problem in Variable Scope vrk1 Excel Programming 3 May 16th 05 06:36 PM
Generic questions about variable scope the Initialize event TBA[_2_] Excel Programming 4 January 12th 04 03:42 PM
Monitoring application-level event problem R Avery Excel Programming 2 January 6th 04 01:58 PM


All times are GMT +1. The time now is 04:42 PM.

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"