Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2017, 09:08 AM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default 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!!
Reply With Quote
  #2  
Old 06-15-2017, 03:26 PM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 06-16-2017, 09:01 AM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default 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
Reply With Quote
  #4  
Old 06-16-2017, 09:49 AM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 06-16-2017, 10:05 AM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default 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
Reply With Quote
  #6  
Old 06-16-2017, 10:12 AM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 06-16-2017, 10:24 AM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default

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!
Reply With Quote
  #8  
Old 06-16-2017, 10:34 AM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Do you have any COM Add-Ins installed. Here is what my Com Add-In list looks like:
Attached Images
File Type: jpg AddIns.jpg (91.9 KB, 16 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #9  
Old 06-16-2017, 10:38 AM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Here is what Prints
Attached Images
File Type: jpg Prints.jpg (206.9 KB, 13 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #10  
Old 06-16-2017, 10:54 AM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default

I have about 10 installed Com Add-ins.

Where do you find the IMMEDIATE window you showed for what Prints?
Reply With Quote
  #11  
Old 06-16-2017, 12:09 PM
gmaxey gmaxey is offline VBA code to enable a Word COM Add-In Windows 7 32bit VBA code to enable a Word COM Add-In Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

The VB Editor "View" menu. Select "Immediate"
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #12  
Old 06-16-2017, 12:26 PM
wordguy wordguy is offline VBA code to enable a Word COM Add-In Windows 10 VBA code to enable a Word COM Add-In Office 2016
Novice
VBA code to enable a Word COM Add-In
 
Join Date: Jun 2017
Posts: 7
wordguy is on a distinguished road
Default

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
Reply With Quote
Reply

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
VBA code to enable a Word COM Add-In 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
VBA code to enable a Word COM Add-In For multiple word document management, is it possible to enable or disable plugin ?? anfas Word 2 11-21-2013 10:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft