I am using OnVariantChanged Event.I want event to be triggered on any changes in Variant name or description.But It is not not getting triggered.And I am not finding cause. any one have idea?
Please post the code you try to run.
I guess it should look like:
Sub Application_OnVariantChanged(Name, oldName, Operation)
I discussed this with Sanjay last week - we had the proper code figured out, but nothing would trig the event. If you have got it running, Oli, I'd be very interested in the solution.
Sanjay - please post you full script
I believe you have already checked this out, but just to double-check...
Have you added below line into your script so as to keep the script running to monitor the event?
Scripting.DontExit = True
Hi - for what it's worth, i have this (I get the event handler message box, so I know it's running). I tried a few events, none is triggered....
'Gets called on any change in variant
MsgBox "Event handler started with Scripting DontExit = "& Scripting.DontExit
MsgBox "Data Changed"
Sub Application_OnVariantChanged(Byval name,Byval oldName,Byval op)
MsgBox "Application_OnVariantChanged:"& name
Dim compname, varname
MsgBox "compname : "& compname &" varname : "&varNAme & " Op : " & op
Function GetKeyObjects ()
Set dxdApp = Application
sFileName = dxdApp.GetProjectData.getProjectPath() & "\variant_impex.txt"
Set vmaddin = Application.Addins("Variant Manager")
If vmaddin Is Nothing Then
Set vmaddin = Application.Addins.Add("MGCVARIANTGUI.MGCVariantGUICtrl.1", "Variant Manager", "")
vmaddin.Visible = True
'MsgBox "vmaddin Is not Nothing"
' vmaddin.Control.VariantGuiApplication is the VM Application object
Set VMApplication = vmaddin.Control.VariantGuiApplication
' VMBOM is the BOM object
Set vmbom = vmaddin.Control.VariantGuiApplication.BOM
' vmdoc is the VMDocument object
Set vmdoc = vmaddin.Control.VariantGuiApplication.VMDocument
VMApplication.VariantMode = Functional
End Function ' GetKeyObjects
The event sub-routines should be attached to Variant Manager Application, not to DxDesigner Application.
So you would need to use Scripting.AttachEvents as below:
Set VarManagerAddin = Application.Addins("Variant Manager")If Not VarManagerAddin Is Nothing Then Scripting.AttachEvents VarManagerAddin.Control.VariantGUIApplication, "varApp"End If
Set VarManagerAddin = Application.Addins("Variant Manager")
If Not VarManagerAddin Is Nothing Then
Scripting.AttachEvents VarManagerAddin.Control.VariantGUIApplication, "varApp"
Accordingly change the name of the event sub-routines so that they start with the prefix "varApp_" as below:
Sub varApp_OnDataChanged() '...End Sub Sub varApp_OnVariantChanged(...) '...End Sub '...
Hope the above helps,
Nick - that did the trick, thanks a million !!
Yes, I confirm.
It works in case a variant is added, deleted or variant name is changed.
Retrieving data ...