From 2d21eb696631e1d33c609c48fedcf3dec79ec4ac Mon Sep 17 00:00:00 2001 From: joyfullservice Date: Fri, 3 Nov 2023 11:48:21 -0500 Subject: [PATCH] Verify ribbon active state when the add-in loads Ensure that the ribbon is active when installing or activating the add-in. See #451 --- .../modules/clsVersionControl.cls | 4 ++++ .../modules/modComAddIn.bas | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Version Control.accda.src/modules/clsVersionControl.cls b/Version Control.accda.src/modules/clsVersionControl.cls index 35c22c47..e0913d46 100644 --- a/Version Control.accda.src/modules/clsVersionControl.cls +++ b/Version Control.accda.src/modules/clsVersionControl.cls @@ -437,6 +437,10 @@ End Sub ' Private Sub Class_Initialize() SaveState + ' When the class is initialized, make sure the ribbon is active (if installed). + ' This way if the COM add-in is not active, it will be automatically activated + ' when the add-in is opened from the [Database Tools\Add-ins] menu. (See #451) + modCOMAddIn.VerifyRibbon End Sub diff --git a/Version Control.accda.src/modules/modComAddIn.bas b/Version Control.accda.src/modules/modComAddIn.bas index f6e328ba..f1ff74c5 100644 --- a/Version Control.accda.src/modules/modComAddIn.bas +++ b/Version Control.accda.src/modules/modComAddIn.bas @@ -87,6 +87,9 @@ Public Sub VerifyComAddIn() ' Reload the add-in to refresh the ribbon UnloadAddIn LoadAddIn + Else + ' Verify that the ribbon is active + VerifyRibbon End If End If @@ -107,6 +110,24 @@ Public Sub ReloadRibbon() End Sub +'--------------------------------------------------------------------------------------- +' Procedure : VerifyRibbon +' Author : Adam Waller +' Date : 11/3/2023 +' Purpose : A lightweight function to verify that the ribbon add-in is active. +' : (It may get turned off if Access is opened in administrator mode.) +'--------------------------------------------------------------------------------------- +' +Public Sub VerifyRibbon() + Dim objAddIn As COMAddIn + Set objAddIn = GetCOMAddIn + If Not objAddIn Is Nothing Then + ' Activate the add-in if it is not currently active + If Not objAddIn.Connect Then objAddIn.Connect = True + End If +End Sub + + '--------------------------------------------------------------------------------------- ' Procedure : UninstallComAddIn ' Author : Adam Waller