Discussion:
Disable COM Addins
(too old to reply)
Venu Gopal
2005-05-18 17:05:33 UTC
Permalink
Hi,


I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.


But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.


How do I disable other Add-ins when my add-in is running.


I have used the following code


For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next


But this dont seem to work. Can anybody help.


Thanks,
Venu
Jean-Guy Marcil
2005-05-18 20:01:53 UTC
Permalink
Post by Venu Gopal
Hi,
I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.
But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.
How do I disable other Add-ins when my add-in is running.
I have used the following code
For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next
But this dont seem to work. Can anybody help.
I do not think that this is the way to go.

If a user finds out after a few weeks worth of headaches that you are
responsible for disabling an Add-in they need for specific tasks... they
will rightly be very annoyed with you, to say the least.

You do not know what another add-in does and if a user needs them or not. So
you cannot blindly disable someone's add-ins..

You have to look at your add-in and find a way to make it work on its own.
Maybe that if disabling a toolbar is of the utmost importance to your
add-in, then you need to find a way to convey that to your users or find
another way around the problem.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
***@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Venu Gopal
2005-05-19 00:01:59 UTC
Permalink
Thanks Jean,

I dint think of it at all. You are right.

Venu
Post by Jean-Guy Marcil
Post by Venu Gopal
Hi,
I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.
But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.
How do I disable other Add-ins when my add-in is running.
I have used the following code
For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next
But this dont seem to work. Can anybody help.
I do not think that this is the way to go.
If a user finds out after a few weeks worth of headaches that you are
responsible for disabling an Add-in they need for specific tasks... they
will rightly be very annoyed with you, to say the least.
You do not know what another add-in does and if a user needs them or not. So
you cannot blindly disable someone's add-ins..
You have to look at your add-in and find a way to make it work on its own.
Maybe that if disabling a toolbar is of the utmost importance to your
add-in, then you need to find a way to convey that to your users or find
another way around the problem.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
Word MVP site: http://www.word.mvps.org
Venu Gopal
2005-05-19 00:17:51 UTC
Permalink
Post by Venu Gopal
Thanks Jean,
I dint think of it at all. You are right.
Venu
Post by Jean-Guy Marcil
Post by Venu Gopal
Hi,
I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.
But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.
How do I disable other Add-ins when my add-in is running.
I have used the following code
For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next
But this dont seem to work. Can anybody help.
I do not think that this is the way to go.
If a user finds out after a few weeks worth of headaches that you are
responsible for disabling an Add-in they need for specific tasks... they
will rightly be very annoyed with you, to say the least.
You do not know what another add-in does and if a user needs them or
not.
Post by Venu Gopal
So
Post by Jean-Guy Marcil
you cannot blindly disable someone's add-ins..
You have to look at your add-in and find a way to make it work on its own.
Maybe that if disabling a toolbar is of the utmost importance to your
add-in, then you need to find a way to convey that to your users or find
another way around the problem.
Infact my need is to do enabling/disabling for only some specific files, not
for all. I will reset the Commandbar states and Add-ins state if the user go
out of the document using Windows_Deactivate, Windows_Activate and also
Window_documentBeforeclose.

But inspite of doing the above there may still be problems when user's
computer is shutdown unexpectedly because there is no event firect then. Can
you please suggest me a workaround for the problem. I can convey all of this
to user and the user should be perfectly alright with this as it will be
only for specific files.
Post by Venu Gopal
Post by Jean-Guy Marcil
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
Word MVP site: http://www.word.mvps.org
Jean-Guy Marcil
2005-05-19 01:01:12 UTC
Permalink
Post by Venu Gopal
Post by Venu Gopal
Thanks Jean,
I dint think of it at all. You are right.
Venu
Post by Jean-Guy Marcil
Post by Venu Gopal
Hi,
I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.
But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.
How do I disable other Add-ins when my add-in is running.
I have used the following code
For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next
But this dont seem to work. Can anybody help.
I do not think that this is the way to go.
If a user finds out after a few weeks worth of headaches that you
are responsible for disabling an Add-in they need for specific
tasks... they will rightly be very annoyed with you, to say the
least.
You do not know what another add-in does and if a user needs them
or not. So you cannot blindly disable someone's add-ins..
You have to look at your add-in and find a way to make it work on
its own. Maybe that if disabling a toolbar is of the utmost
importance to your add-in, then you need to find a way to convey
that to your users or find another way around the problem.
Infact my need is to do enabling/disabling for only some specific
files, not for all. I will reset the Commandbar states and Add-ins
state if the user go out of the document using Windows_Deactivate,
Windows_Activate and also Window_documentBeforeclose.
Have you looked into the DocumentChange event? Might be easier, no?
Post by Venu Gopal
But inspite of doing the above there may still be problems when user's
computer is shutdown unexpectedly because there is no event firect
then. Can you please suggest me a workaround for the problem. I can
convey all of this to user and the user should be perfectly alright
with this as it will be only for specific files.
If your add-in is launched with Word, it can first check if everything is as
it should be, and if not, reset everything.
For example, the first thing your add-in could do is check for a variable in
the registry, if it is present with a certain value, everything is OK, then
change this variable. When Word is closed, reset the variable to its initial
value . This way, whenever you launch Word, your add-in will always know if
Word was closed normally the last time it was run.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
***@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Venu Gopal
2005-05-19 01:22:37 UTC
Permalink
Post by Jean-Guy Marcil
Post by Venu Gopal
Post by Venu Gopal
Thanks Jean,
I dint think of it at all. You are right.
Venu
Post by Jean-Guy Marcil
Post by Venu Gopal
Hi,
I have a COM Add-in which works with CommandBars by Enabling and
Disabling them. The code works fine.
But I am concerned if there is another COM Add-in which does the
similar job of enabling and disabling commandbars. So in that case,
what I have done to commandbars may be undone by another Add-in.
How do I disable other Add-ins when my add-in is running.
I have used the following code
For Each addin In App.COMAddIns
If Not addin.Description = "Test Add-in" Then '
"Test Add-in" is the description of my Addin
addin.Connect = False
End If
Next
But this dont seem to work. Can anybody help.
I do not think that this is the way to go.
If a user finds out after a few weeks worth of headaches that you
are responsible for disabling an Add-in they need for specific
tasks... they will rightly be very annoyed with you, to say the
least.
You do not know what another add-in does and if a user needs them
or not. So you cannot blindly disable someone's add-ins..
You have to look at your add-in and find a way to make it work on
its own. Maybe that if disabling a toolbar is of the utmost
importance to your add-in, then you need to find a way to convey
that to your users or find another way around the problem.
Infact my need is to do enabling/disabling for only some specific
files, not for all. I will reset the Commandbar states and Add-ins
state if the user go out of the document using Windows_Deactivate,
Windows_Activate and also Window_documentBeforeclose.
Have you looked into the DocumentChange event? Might be easier, no?
I tried DocumentChange, it is same behaviour. The problem is with Add-Ins,
they function inspite of setting the connect property to false.
Is it because that connection to an Add-in is made much before any of this
above events are executed ?
I cannot put the code in Connect event (Implementation of
IDTExtensibility2), because at this point I will not know if the document
belongs to my list.
Post by Jean-Guy Marcil
Post by Venu Gopal
But inspite of doing the above there may still be problems when user's
computer is shutdown unexpectedly because there is no event firect
then. Can you please suggest me a workaround for the problem. I can
convey all of this to user and the user should be perfectly alright
with this as it will be only for specific files.
If your add-in is launched with Word, it can first check if everything is as
it should be, and if not, reset everything.
For example, the first thing your add-in could do is check for a variable in
the registry, if it is present with a certain value, everything is OK, then
change this variable. When Word is closed, reset the variable to its initial
value . This way, whenever you launch Word, your add-in will always know if
Word was closed normally the last time it was run.
Thanks for this workaround will do this.
Post by Jean-Guy Marcil
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
Word MVP site: http://www.word.mvps.org
Loading...