#1
|
|||
|
|||
VBA code to enable a Word COM Add-In
One of our firm's Word add-ins in the COM Add-ins group is causing some freezing issues on occasion in Word when enabled. The add-in is very important for some users, so we'd like to give them the choice of easily enabling or disabling it, depending on what they're doing in Word. I have tried all kinds of VBA code involving Application.COMAddIns, but can't find the correct code to assign to a couple of buttons on the Quick Access Toolbar, one which would enable the add-in, the other to disable it. All meant to save the user time instead of having to go to File/Options/Add-ins/Manage COM Add-ins every time to either enable or disable the add-in.
Any help would be greatly appreciated. Thank you!! |
#2
|
|||
|
|||
Something like this:
Code:
Option Explicit Sub DisconnetCOMAI() Dim lngIndex As Long Dim oCAIs As COMAddIns Set oCAIs = Application.COMAddIns For lngIndex = 1 To oCAIs.Count If Application.COMAddIns(lngIndex).Description = "Microsoft Word Code Compatibility Inspector" Then Application.COMAddIns(lngIndex).Connect = False Exit For End If Next End Sub Sub ConnectCOMAI() Dim lngIndex As Long Dim oCAIs As COMAddIns Set oCAIs = Application.COMAddIns For lngIndex = 1 To oCAIs.Count If Application.COMAddIns(lngIndex).Description = "Microsoft Word Code Compatibility Inspector" Then Application.COMAddIns(lngIndex).Connect = True Exit For End If Next End Sub |
#3
|
|||
|
|||
VBA code to enable a Word COM Add-In
Hi Greg,
Thanks so much for your reply. Your code looks really good. It worked for one of my COM Add-Ins, but not for most of them. Not sure why. It probably has to do with something going on in the background of our system. Just wanted to say thanks for your work. Have a great day! Kurt |
#4
|
|||
|
|||
You might try printing the list of Com Add-ins to make sure you are using the correct descriptor.
For lngIndex = 1 To oCAIs.Count Debug.Print Application.COMAddIns(lngIndex).Description |
#5
|
|||
|
|||
VBA code to enable a Word COM Add-In
Thanks for the idea Greg.
I've put your code into the following: Sub printdescriptions() Dim lngIndex As Long Dim oCAIs As COMAddIns Set oCAIs = Application.COMAddIns For lngIndex = 1 To oCAIs.Count Debug.Print Application.COMAddIns(lngIndex).Description Exit For Next End Sub Nothing prints. Ideas? Thanks. Kurt |
#6
|
|||
|
|||
Well if the first one doesn't have a description defined it wouldn't print and then none of the rest would because you are exiting the For ... Each loop.
The idea is to try to find a unique identifier for the Add-in you want to disconnect. Try: Sub printdescriptions() Dim lngIndex As Long Dim oCAIs As COMAddIns Set oCAIs = Application.COMAddIns For lngIndex = 1 To oCAIs.Count Debug.Print Application.COMAddIns(lngIndex).Description Debug.Print Application.COMAddIns(lngIndex).ProgID Debug.Print Application.COMAddIns(lngIndex).GUID Next End Sub |
#7
|
|||
|
|||
I copied your EXACT coding into a new macro. Still nothing prints.
Should I be changing something in your code? Thanks a lot for your help! |
#8
|
|||
|
|||
Do you have any COM Add-Ins installed. Here is what my Com Add-In list looks like:
|
#9
|
|||
|
|||
Here is what Prints
|
#10
|
|||
|
|||
I have about 10 installed Com Add-ins.
Where do you find the IMMEDIATE window you showed for what Prints? |
#11
|
|||
|
|||
The VB Editor "View" menu. Select "Immediate"
|
#12
|
|||
|
|||
BINGO!
I found the descriptions in the Immediate window, and discovered that in fact the descriptions are NOT what they appear to be in the "Description" area at the bottom of the COM Add-ins windows. I copied and pasted the actual description for the COM Add-in I wanted to enable and disable, inserted it into your previous code, and voila--it works. Many, many thanks for sticking with me! I believe you've helped me in times past, and I'm very appreciative for your professionalism, patience and expertise. Bravo!! Kurt |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with Word VBA code to enable a COM Add-In | wordguy | Word VBA | 0 | 06-13-2017 01:52 PM |
Force a user to enable macros in Powerpoint? Hide sheets until the "enable" button is clicked | copleyr | PowerPoint | 1 | 10-07-2016 01:15 AM |
How to automatically enable macros upon opening the Word? | laurieli | Word VBA | 2 | 12-22-2015 02:46 PM |
VBA code to enable Regular Expression | ronmayerle | Word VBA | 2 | 11-20-2014 01:09 PM |
For multiple word document management, is it possible to enable or disable plugin ?? | anfas | Word | 2 | 11-21-2013 10:23 PM |