ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unhook (then rehook) workbook events??? (https://www.excelbanter.com/excel-programming/287950-unhook-then-rehook-workbook-events.html)

Tim Williams

Unhook (then rehook) workbook events???
 

I'm working with an application which automates Excel to host a "Report"
workbook. There are various types of "sessions" during which a user can
interact with the workbook in a more or less limited way (eg. saving of the
workbook under another name is not permitted).

It seems that in one particular session type the controlling application has
hooked the Workbook_Beforesave event such that choosing "Save" from the
Excel menu calls a particular piece of code but does not save the workbook.

Anyone know whether it's possible (without access to the controlling code)
to "unhook" the Beforesave event temporarily so that I can save the
workbook, and then "rehook" the event ?

Thanks for any ideas,
Tim.



Tim Zych[_4_]

Unhook (then rehook) workbook events???
 
Application.EnableEvents = False
' run whatever you want
Application.EnableEvents = True

since it's application level, not sure if it's what you want. It also
disables more than just the BeforeSave event.


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...

I'm working with an application which automates Excel to host a "Report"
workbook. There are various types of "sessions" during which a user can
interact with the workbook in a more or less limited way (eg. saving of

the
workbook under another name is not permitted).

It seems that in one particular session type the controlling application

has
hooked the Workbook_Beforesave event such that choosing "Save" from the
Excel menu calls a particular piece of code but does not save the

workbook.

Anyone know whether it's possible (without access to the controlling code)
to "unhook" the Beforesave event temporarily so that I can save the
workbook, and then "rehook" the event ?

Thanks for any ideas,
Tim.





Tim Williams

Unhook (then rehook) workbook events???
 
Tim,

Thanks - I hadn't thought of that. Will try tomorrow and post back
with the outcome.

Tim.


"Tim Zych" wrote in message
...
Application.EnableEvents = False
' run whatever you want
Application.EnableEvents = True

since it's application level, not sure if it's what you want. It

also
disables more than just the BeforeSave event.


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...

I'm working with an application which automates Excel to host a

"Report"
workbook. There are various types of "sessions" during which a

user can
interact with the workbook in a more or less limited way (eg.

saving of
the
workbook under another name is not permitted).

It seems that in one particular session type the controlling

application
has
hooked the Workbook_Beforesave event such that choosing "Save"

from the
Excel menu calls a particular piece of code but does not save the

workbook.

Anyone know whether it's possible (without access to the

controlling code)
to "unhook" the Beforesave event temporarily so that I can save

the
workbook, and then "rehook" the event ?

Thanks for any ideas,
Tim.







Tim Williams

Unhook (then rehook) workbook events???
 
OK - works well. Thanks for the tip.

Tim.



"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...
Tim,

Thanks - I hadn't thought of that. Will try tomorrow and post back
with the outcome.

Tim.


"Tim Zych" wrote in message
...
Application.EnableEvents = False
' run whatever you want
Application.EnableEvents = True

since it's application level, not sure if it's what you want. It

also
disables more than just the BeforeSave event.


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...

I'm working with an application which automates Excel to host a

"Report"
workbook. There are various types of "sessions" during which a

user can
interact with the workbook in a more or less limited way (eg.

saving of
the
workbook under another name is not permitted).

It seems that in one particular session type the controlling

application
has
hooked the Workbook_Beforesave event such that choosing "Save"

from the
Excel menu calls a particular piece of code but does not save the

workbook.

Anyone know whether it's possible (without access to the

controlling code)
to "unhook" the Beforesave event temporarily so that I can save

the
workbook, and then "rehook" the event ?

Thanks for any ideas,
Tim.










All times are GMT +1. The time now is 03:39 PM.

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