How to start Word without COM addins?

C

Chango V.

Hello,

We need to automate Word externally, in a somewhat repetitive manner. But we
also have a .NET-based COM addin, which slows Word down considerably on
startup. Is there a reliable way to suppress addin loading when calling
CreateObject("Word.Application")? I know Word supports the /a command-line
option, but how to apply it when creating an instance programmatically?

As a last resort, we could temporarily unregister the COM addin before
starting Word externally, but this is really brutish and might cause a
permanent problem if something goes wrong in the controller application. Any
better idea will be appreciated.

Thanks.

// Chango V.
 
W

Wei-Dong Xu [MSFT]

Hi Chango,

Thanks for posting in the community!

From my understanding to this issue, you installed one .net-based com
add-in in word. When you start up the work through automation, the
initialization of this com add-in spent a lot of time which make the
initialization very slow.

There are two types of add-in in word: wll add-in and com add-in, which are
different. I'd suggest one MSDN article will introduce more information
regarding this:
COM Add-ins vs. Application-Specific Add-ins
http://msdn.microsoft.com/library/en-us/odeopg/html/deovrcomaddinsvsapplicat
ionspecificaddins.asp

The /a startup switch is used to disable the wll add-in and global
templates for Word. Com add-in will not be affected.

For the com add-in initialization, based on my experience, I'd suggest
there are two methods for you in this scenario.
1) The method you have mentioned in the above message, you can unregister
the add-in before you starts Word and register it when necessary. As you
have said, this is not very easy for the users.
2) You can disable the com add-in and then enable it when necessary. When
the user exists the word, he should disable the com add-in so that the next
startup initialization will not be affected. This method will be very
helpful in this scenario. You can tell the users to enable or disable the
com add-in manually or control this with automation. I write one VBA code
for you on this.
'Code begin ----------------------------------------------------
Sub EnableorDisableComAddIn()

Dim oCtlAddinMgr As COMAddIns
Dim oCtlAddin As COMAddIn
On Error GoTo ErrHandler

Set oCtlAddinMgr = Application.COMAddIns

For Each oCtlAddin In oCtlAddinMgr
'Please specify the progID of the .net-based com add-in here.
'then set the true/false to the Connect property to enable or
'disable the com add-in
If oCtlAddin.ProgID = "TestAddin.MyAddin" Then
If oCtlAddin.Connect = False Then
oCtlAddin.Connect = True
MsgBox oCtlAddin.ProgID & " " & "connected!"
Else
oCtlAddin.Connect = False
MsgBox oCtlAddin.ProgID & " " & "dis-connected!"
End If
End If
Next

Exit Sub

ErrHandler:
Debug.Print Err.Number & " "; Err.Description
End Sub
'Code end ------------------------------------------------------

If you use the VBA code to control the com add-in loading, The document
open and close event will help you a lot to enable and disable the com
addin. You can take advantage of the document level or application level
event(in the template) to perform the operation.

Please feel free to let me know if you have any further questions. I am
standing by to be of assistance.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tom Winter

Chango V. said:
Hello,

We need to automate Word externally, in a somewhat repetitive manner. But we
also have a .NET-based COM addin, which slows Word down considerably on
startup. Is there a reliable way to suppress addin loading when calling
CreateObject("Word.Application")? I know Word supports the /a command-line
option, but how to apply it when creating an instance programmatically?

As a last resort, we could temporarily unregister the COM addin before
starting Word externally, but this is really brutish and might cause a
permanent problem if something goes wrong in the controller application. Any
better idea will be appreciated.

Thanks.

// Chango V.

You could change the LoadBehavior key in the registry for each add-in before
starting Word. That's less drastic than unregistering the whole add-in.

-Tom
 
C

Chango V.

Thank you for the detailed response! As Tom W. is also suggesting, we may
resort to flipping the addin's LoadBehavior. I just wanted to hear
first-hand from Microsoft that there isn't a safer, official way to do what
we want.

I made this hopeless experiment: Found the Word.Application object's
registration and added "/a" to the command line starting WinWord.exe. But it
seems that Word simply ignores any other options when it sees "/automation"
(which is what the standard registration has). I know this is like breaking
the COM rules, but it would be nice to have some way to pass command-line
options when creating Word.Application...

It is also regrettable that a .NET-based COM addin takes so long to load. I
guess a big part of this is just the initialization of the CLR in the
WinWord process. I wish Microsoft did some system-level hack to exempt
Office addins from this hefty penatly... There's also the JIT compilation,
but I guess it can be helped a little by doing NGEN on the addin first. (We
haven't tried this yet.)

We are actually now thinking about creating a "shim" addin in C++ that will
load in on time on startup and only set up the GUI customizations for the
COM add-in. When the user first attempts to use the COM add-in, it will be
loaded on the fly. Thus we can save the Word startup delay. The bonus is we
can also avoid the known macro-security issues with .NET-based COM addins...

// Chango V.
 
W

Wei-Dong Xu [MSFT]

Hi Chango,

Thank you for replying and the detailed information and suggestion
concerning the .net-based com add-in of Word!

I think your suggestion is very helpful for us to speed up the
initialization of word with the .Net-based Com add-in. This is a great idea
for a future word enhancement. I'd recommend that you forward the
recommendation to the Microsoft Wish Program:
1. World Wide Web
a)In Internet Explorer 6, click Send Feedback on the Help menu and then
click the link in the Product Suggestion section of the page that appears.
b)In Windows XP, click Help and Support on the Start menu. Click Send
your feedback to Microsoft, and then fill out the Product Suggestion page
that appears.
c)Visit the following Microsoft Web site:
http://www.microsoft.com/ms.htm
d)Click Microsoft.com Guide in the upper-right corner of the page and
then click Contact Us . Click the link in the Product Suggestion section of
the page that appears.
e)Visit the following Microsoft Product Feedback Web site
http://register.microsoft.com/mswish/suggestion.asp
and then complete and submit the form.

2. E-mail - To send comments or suggestions via e-mail, use the following
Microsoft Wish Program e-mail address, (e-mail address removed).

3. FAX - To send comments or suggestions via FAX, use the following
Microsoft FAX number, (425) 936-7329.
NOTE : Address the FAX to the attention of the Microsoft Wish Program.

4. US Mail - To send comments or suggestions via US Mail, use the following
Microsoft mailing address:
Microsoft Corporation
Attn. Microsoft Wish Program
One Microsoft Way
Redmond, WA 98052-6399

Please feel free to let me know if you have any further questions.

Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------------------------------------------------------
MORE INFORMATION
Each product suggestion is read by a member of our product feedback team,
classified for easy access, and routed to the product or service team to
drive Microsoft product and/or service improvements. Because we receive an
abundance of suggestions (over 69,000 suggestions a year!) we can't
guarantee that each request makes it into a final product or service. But
we can tell you that each suggestion has been received and is being
reviewed by the team that is most capable of addressing it.

All product or service suggestions received become the sole property of
Microsoft. Should a suggestion be implemented, Microsoft is under no
obligation to provide compensation.
 

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