I have a problem with "User-defined type not defined", but I do not want to allow it, I want to ignore it.
Situation: in a text document (.docm) I use an external dll (C #, I create, I have control over it). This dll is used to improve control over the document (importing model details / parameters depending on the search / ...). DLL defines a specific type of user
A custom dll is called when the user clicks a button. It checks if the dll is loaded or not. If not, a message like “Actions disabled” will be displayed.
Call example:
' This call is from "ThisDocument" Private Sub planAction_Click() ' If the dll is not load, display warning message If Not MqDllInstalled Then Call MsgBox("Actions disabled", vbInformation, "Action unavailable") Exit Sub End If ' This function is in a module Call FuncPlanAction End Sub
he calls
Public Sub FuncPlanAction() ... If exist Then ' WordElementType_PlanAction is a "User-Type Defined" Call GotoTable(WordElementType_PlanAction, Now) End If ... End Sub
and definition of GotoTable
Private Sub GotoTable(ByVal name As WordElementType, ByVal dt As Date)
So, if I click the "planAction" button, instead of displaying the message "Actions are disabled", it raises "User-defined type is not defined", because it is trying to enable FuncPlanAction.
What I want: that the error does not occur.
Why not decide: The document should be shared, and if the link is not available, I will simply disable the advanced features.
What i know:
- where the problem arises from: the link is not resolved, therefore, it does not determine the type defined by the user.
- How the VBA compiler works: it tries to load a module as soon as a call is made in it (and if this module calls another module, this will happen). Therefore, until I call the module with Custome User-Type, no "User-Type" will go up.
What I tried:
- I have a module, a separate module "LoadDll" without a specific type of user who is trying to load a custom dll. If it can’t find the dll / tlb to load, the error does not occur when loading.
- Surround the caller with
On error goto / On error resume next (in planAction_Click and FuncPlanAction ) - Put the function in another module
Does anyone know how to catch this bug? not raise? Any other suggestions?
thanks in advance