how to remove toolbar from normal.dot?

P

Peter Huang [MSFT]

Hi

You are welcomed!
I am glad that my suggestion helps you.
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

Depending on context there may not be any active documents by the time
shutdown fires. In that case you'd have to handle an event for each open
document at the Close event.
 
J

Jerry Nettleton

So if GetActiveDocument() causes an exception (instead of NULL), then what
can I use to determine if there's an active document?
 
K

Ken Slovak - [MVP - Outlook]

In VBA/VB type code:

On Error Resume Next
Set objDoc = oWord.ActiveDocument
If objDoc Is Nothing Then
Err.Clear
'no active doc


Or if you have handlers for each document that are instantiated in classes
stored in a collection you would have a global Long that would serve as a
document counter. Each Word.Application.DocumentOpen event would increment
the Long, Each DocumentBeforeClose event would decrement the counter. If the
counter is 0 there is no new ActiveDocument and no open documents.

In addition, for each document class you create for handling document events
you can select to handle the Document.Close event.
 
J

Jerry Nettleton

I had to revisit this problem since this solution caused duplicate menu
buttons when I restarted Word. So I opened an incident and the support
person recommended disabling all temporary flags. I then added the
following code after removing the toolbar and menus buttons in
OnDisconnection method:

TemplatePtr spNormal = m_spApplication->NormalTemplate;
spNormal->Save();

This code removes the add-in from 'normal.dot' when it is
disabled/disconnected. But now I need to find a way to safely uninstall COM
add-ins. It seems like I need to find a way for InstallShield to call
OnDisconnection so that I can clean up the 'normal.dot' file.

Jerry
 
P

Peter Huang [MSFT]

Hi

I think the OnDisconnection should be called by Winword.
What you should make sure is that once winword is exit the COM Addin will
remove the Toolbar and set the normal.dot clear.
From your scenario, I think you may try to check if the winword.exe is
running, if yes, please pop up a messagebox to tell the customer that the
he should exit winword first.
For other information about installshield, I think you would better
contact their support
http://www.macrovision.com/support/index.shtml

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jerry Nettleton

Since turning temporary flags ON causes menu problems and OFF causes the use
of 'normal.dot' and uninstall problems, do you have any other suggestions?

I was expecting to find a Microsoft knowledge-based article on how to
uninstall a COM add-in. It's not as simple as using 'regsvr32 /u' and
removing the Word add-in registry key. So you're are saying that I need
programatically run Word.exe and execute a script to disable my COM add-in?
Do you have any examples or ideas on where to start looking to disable the
COM add-in from a script?

Jerry
 
P

Peter Huang [MSFT]

Hi

Let us check how a common COM-Addin works?
When we install a COM Addin, it will set in two places in the registry.
1.register the COM Information(regsvr32)
2.HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Word\Addins\<addin classname>
or
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Word\Addins\<addin classname>

Commonly this information will be cleared by the installer of Word Addin(
when we create a word addin in vs.net, it will create an addin setup
project automatically).

That is to say for a common addin which did not interactive with
normal.dot, all is OK.

But if we changed information in normal.dot, the addin setup project did
not know how to remove the information in the normal.dot, because commonly
it is just a special .NET class library it have no idea to the structure of
normal.dot, and it is not its job to do that. Since the normal.dot's
structure is not public, only winword.exe know how to do that, so it is the
winword's job to do the clear job. And the Com-addin is mainly interactive
with Word, the OnDisconnection and similar job should be called inside the
word, and even if hypothetically we can call the OnDisconnection outside
the winword, but the code inside the method that clear the toolbar
information still need winword's help, because that is the Word's Object
Modal. Just as if we wants to automation Word to do some job, we must
installed/lauched word.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jerry Nettleton

"common addin which did not interactive with normal.dot" -- that's why I
started this thread and wanted to turn on the temporary flag but that
approach caused menu problems (i.e. Microsoft bugs that they're not ready to
fix or find the root cause of the problem).

So to resolve the menu problems, I had to use a work-around (from a recent
MS incident) and turn off the temporary flag which creates uninstall problems
(since it uses normal.dot).

Based on your last message, it appears you don't have any articles on how to
uninstall a COM add-in completely (with the temporary flag turned off). I
did find a command line switch (/laddinpath -- Start Word and then load a
specific Word add-in. Example: /lSales.dll) which might help but now I need
to create a macro that uses the Word object model to find my add-in, disable
it, and then exit Word.

Or perhaps the best solution is to avoid touching normal.dot altogether.
Are there any knowledge based-articles available? I'm assuming it has
something to do with CustomizationContext...

Thanks,
Jerry
 
P

Peter Huang [MSFT]

Hi

I am sorry if I did not make it clear.
A com addin is just a class library which implement the standard addin
interface.
e.g. if the ComAddin's certain function, we create a file on the disk, but
in the COM Addin Setup level, it have no idea which file it will should
delete, because that may differ. That is to say, if we do a job in the
comaddin, we should do the reverse job to remove the change. But as we said
before, we use Word's OM to change toolbar, we also need the Word'OM to
remove the change.

Just as we can make change to the normal.dot via UI/VBA code. To the
ComAddin level it should be isolated from the how and when it is used.
e.g. an COM Addin can attach to Excel/PowerPoint ....,it just give your the
chance to use the framework(Addin Interface implement) to change the Word's
behavior, but the concrete change and unchange should be maintain by
yourself. e.g. You create a file, then in the uninstall you need to delete
file.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jerry Nettleton

Actually, you made it very clear the first time, the second time, and now the
3rd time.

I'm only looking for a way for the unistall process to call
OnDisconnection(). If that means launching Word with a command line switch,
that's fine. The OnDisconnection() method takes care of all the cleanup to
normal.dot.

Since you haven't responded with articles or ideas on how to do this, does
anyone else have any ideas?

Thanks,
Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top