Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: frederic.vandenplas

Thank you so much for your help. I’m still having a little trouble. Below is the code I’m using in visual basic for a button command. It is not understanding “Thisapplication” command. Frederic you code worked great when run in a rule. I just can get it to work in the application I’m trying to make. I would appreciate if you could look this code over to see what I’m doing wrong. I know that it’s close.

Thank you

 

SyntaxEditor Code Snippet

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If _invApp.Documents.Count = 0 Then
            MsgBox("Need to open an Assembly document")
            Return
        End If

        If _invApp.ActiveDocument.DocumentType <> _
        DocumentTypeEnum.kAssemblyDocumentObject Then
            MsgBox("Need to have an Assembly document active")
            Return
        End If

        Dim asmDoc As AssemblyDocument
        asmDoc = _invApp.ActiveDocument

        Dim oAsmDoc As AssemblyDocument = _invApp.ActiveDocument
        Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
        Dim oBOM As BOM = oAsmDef.BOM

        Dim filename As String = "P:\Engineering\Inventor\BOM List\Profit Key BOM.xml"
        Call oBOM.ImportBOMCustomization(filename)

        'Open BOM editor dialog box
        Dim oCtrlDef As ControlDefinition
        oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
        oCtrlDef.Execute()

  End Sub