ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable the "X" close button in an excel application (https://www.excelbanter.com/excel-programming/327702-re-disable-x-close-button-excel-application.html)

Tempy

Disable the "X" close button in an excel application
 
Hi keepITcool,

I have Inserted your code into my object module but the sentance, "Dim
WithEvents xlApp As Application", keeps giving me an error.

Could you possibly help ?

Thanks

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

keepITcool

Disable the "X" close button in an excel application
 

I dont know what you consider 'my object module'
my code is meant to go in the code module of Thisworkbook object.
NOT in a normal module. that was the whole point.


open VBE
double click ThisWorkbook in Project Explorer.
a code pane opens (or is activated) titled:
BookX.xls - ThisWorkbook[code]

copy my code there. (and remove it anywhere else)

now you should be able to use the dropdowns at the top
of the codepane and select the General and the objects workbook and
xlapp

... note if you select xlApp in the LEFT dropdown..
the available events are listed on the Right.


From VBA help:

WithEvents Optional. Keyword that specifies that varname is an object
variable used to respond to events triggered by an ActiveX object.

WithEvents is valid only in class modules.

You can declare as many individual variables as you like using
WithEvents, but you can't create arrays with WithEvents. You can't use
New with WithEvents.

Re 'WithEvents is valid only in class modules.':
modules behind a userform, worksheet or thisworkbook
are defacto classmodules.






--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tempy wrote :

Hi keepITcool,

I have Inserted your code into my object module but the sentance, "Dim
WithEvents xlApp As Application", keeps giving me an error.

Could you possibly help ?

Thanks

Tempy

*** Sent via Developersdex http://www.developersdex.com ***


Tempy

Disable the "X" close button in an excel application
 
Hi KeepITcool,

Thanks very much, i found the problem and it working just great, thanks
for all the help and understanding.

I seem to have created quite a bit of dialog with this subject!!

Thanks again for a great job to all.

best regards,

Tempy

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips[_6_]

Disable the "X" close button in an excel application
 
Troublemaker :-)


"Tempy" wrote in message
...
Hi KeepITcool,

Thanks very much, i found the problem and it working just great, thanks
for all the help and understanding.

I seem to have created quite a bit of dialog with this subject!!

Thanks again for a great job to all.

best regards,

Tempy

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com