Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

@bradeneuropeArthur ,

 

I actually got this same error again. In my implementation, I deactivate first, then active at the end. Here is my code. It is basically showing a userform that allows the user to pick the macro they want to run. Only certain macros need the vault add-in unloaded.

Sub UniversalNew()

strSoftwareName = "Abtex Inventor Suite " & strVersion

Dim boolUnloadVault As Boolean
boolUnloadVault = True

iActiveScreen = 0
CurrentEnvironmentNew = ActiveEnvironmentNew

SelectedProgramNew = vbNullString
UniversalFormComplete = False
UniversalFormCancelled = False

UserForm_Universal.Label_Message.Caption = vbNullString
UserForm_BillOfMaterial.Label_Message.Caption = vbNullString
UserForm_OtherMacros.Label_Message.Caption = vbNullString

UserForm_Universal.Caption = strSoftwareName
UserForm_BillOfMaterial.Caption = strSoftwareName & " - Bill of Material"
UserForm_OtherMacros.Caption = strSoftwareName & " - Other macros"

'Run Userform to collect information
UserForm_Universal.Show

Do Until UniversalFormComplete = True
    
DoEvents

Loop

If UniversalFormCancelled = True Then
    
    'MsgBox "User Cancelled. Click Okay to terminate."
    End
    
End If

Dim aai As ApplicationAddIn
Set aai = ThisApplication.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}")

Select Case SelectedProgramNew

    Case "BOM"
        If boolUnloadVault = True Then aai.Deactivate 'ThisApplication.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}").Deactivate
        Call ExportBOM.ExportBOM
    Case "Format BOM"
        Call FormatBOM.FormatBOM
    Case "Generate Thumbnails"
        If boolUnloadVault = True Then aai.Deactivate 'ThisApplication.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}").Deactivate
        Call GenerateThumbnails.GenerateThumbnails
    Case "Generate Brush"
        Call MakeBrush_Tufted.TuftedBrush
    Case "Create GPN"
        Call FillProperties.CreateGPN
    Case "Finish"
        Call MakeFinish.MakeFinish
    Case "Toggle Part Number"
        Call ToggleColumnVisibility.TogglePartNumber
    Case "Determine Parents"
        Call FillProperties.DetermineParents
    Case "Rename Occurences"
        Call RenameOccurences.RenameOccurences
    Case "Export Drawings"
        If boolUnloadVault = True Then aai.Deactivate 'ThisApplication.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}").Deactivate
        Call ExportDrawings.Main
    Case "Merge BOMs"
        Call MergeBOMs.MergeBOMs
    Case "Merge PDFs"
        Call OpenPDFSAM.OpenPDFSAM
    Case "Copy Sheet"
        Call CopySheet.IDW_DuplicateSheet
    Case "Add Part Number"
        Call AddPartNumber.AddPartNumber
    Case "Add Layer PN"
        Call AddPartNumber.AddLayerPN
    Case "Import Fastener"
        Call ImportFastener.ImportFastener
    Case "Delete Custom Properties"
        Call DeleteCustomProperties.DeleteCustomProperties
    Case "Adjust View"
        Call AdjustView.CallUserForm
    Case "Check Param and Rule"
        Call AddPartNumber.CheckParamAndRule
    Case Else
        MsgBox "An error has occured."
End Select

'Reactivate Vault is failing
If boolUnloadVault = True Then aai.Activate 'ThisApplication.ApplicationAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}").Activate
Set aai = Nothing
'MsgBox "Ending program"
End
End Sub

 

Any idea what might be happening? Any help would be appreciated.

 

Thank you.

Rafael