AnsweredAssumed Answered

EPDM API for BoM Extraction in VBA

Question asked by Guy Edkins on Aug 8, 2018
Latest reply on Oct 29, 2019 by Guy Edkins



        Dim BOM As IEdmBomView3


        Set BOM = eFile.GetComputedBOM("Standard Roll Up BOM", -1, ConfigName, EdmBomFlag.EdmBf_ShowSelected)


       ' Call BOM.SaveToCSV("c:\temp\guy.txt", True)



        Dim fso As New FileSystemObject

        Dim sw As TextStream

        Set sw = fso.CreateTextFile("c:\temp\" & AssyName & ".txt")



        '-----------------------------GET COLUMN HEADERS

        Dim columns() As EdmBomColumn

        BOM.GetColumns columns

        Dim header As String

        header = "LEVEL" & vbTab

        Dim column As EdmBomColumn

        For i = 0 To UBound(columns)

            header = header & columns(i).mbsCaption & vbTab


        sw.writeline (header)

       ' -----------------------------Bom.READ EACH BOM ROW


    Dim varVal As String

    Dim rows() As Variant

    Dim row As IEdmBomCell

    Dim rowstring As String

     Call BOM.GetRows(rows)

        For p = 0 To UBound(rows)

            Set row = rows(p)

                rowstring = row.GetTreeLevel & vbTab

                varVal = ""


              For i = 0 To UBound(columns)

                    column = columns(i)

                    Call row.GetVar(column.mlColumnID, column.meType, varVal, Nothing, "", True)  <= varval never returns a value even though columns are being incremented, see above image showing variable watches.

                    rowstring = rowstring & varVal & vbTab

                    Debug.Print rowstring


                '-----------------------------WRITE THE ROW TO THE FILE

               sw.writeline (rowstring)