Private Sub cmdTranslate_Click()
    Dim oEdiDoc As Fredi.ediDocument
    Dim oSchema As Fredi.ediSchema
    Dim oSchemas As Fredi.ediSchemas
    Dim oSegment As Fredi.ediDataSegment
    Dim sSegmentID As String
    Dim sLoopSection As String
    Dim nArea As Integer
    Dim sValue As String
    Dim sQlfr As String
    Dim sNadLoopEntity As String
    
    Dim sSefFile As String
    Dim sEdiFile As String
    Dim sPath As String
    
    sPath = Application.ActiveWorkbook.Path & "\"
    sSefFile = "IFTMIN_D99B.EVAL0.SEF"  'EVALUATION SEF FILE
    sEdiFile = "IFTMIN_D99B.edi"
    
    
    'CREATES EDIDOC OBJECT
    Set oEdiDoc = New Fredi.ediDocument
    
    'THIS MAKES CERTAIN THAT FREDI ONLY USES THE SEF FILE PROVIDED, AND THAT IT DOES
    'NOT USE ITS BUILT-IN STANDARD REFERENCE TABLE TO GENERATE THE EDI FILE.
    Set oSchemas = oEdiDoc.GetSchemas
    oSchemas.EnableStandardReference = False
    
    'THIS OPTIONS STOPS FREDI FROM KEEPING ALL THE SEGMENTS IN MEMORY
    oEdiDoc.CursorType = Cursor_ForwardOnly
    
    'GET TERMINATORS
    oEdiDoc.SegmentTerminator = "'{13:10}"
    oEdiDoc.ElementTerminator = "+"
    oEdiDoc.CompositeTerminator = ":"
    oEdiDoc.ReleaseIndicator = "?"
    
    'LOADS THE SEF FILE
    Set oSchema = oEdiDoc.LoadSchema(sPath & sSefFile, 0)
    
    'LOADS THE EDI FILE
    oEdiDoc.LoadEdi sPath & sEdiFile
    
    'GETS THE FIRST DATA SEGMENT
    Set oSegment = oEdiDoc.FirstDataSegment
    
    'LOOP THAT WILL TRAVERSE THRU EDI FILE FROM TOP TO BOTTOM
    Do While Not oSegment Is Nothing
    
        'DATA SEGMENTS WILL BE IDENTIFIED BY THEIR ID, THE LOOP SECTION AND AREA
        '(OR TABLE) NUMBER THAT THEY ARE IN.
        sSegmentID = oSegment.ID
        sLoopSection = oSegment.LoopSection
        nArea = oSegment.Area
    
        If nArea = 0 Then
            If sLoopSection = "" Then
                If sSegmentID = "UNB" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Syntax identifier
                    sValue = oSegment.DataElementValue(1, 2)    'Syntax version number
                    sValue = oSegment.DataElementValue(2, 1)    'Interchange sender identification
                    sValue = oSegment.DataElementValue(2, 2)    'Partner identification code qualifier
                    sValue = oSegment.DataElementValue(3, 1)    'Recipient identification
                    sValue = oSegment.DataElementValue(3, 2)    'Partner identification code qualifier
                    sValue = oSegment.DataElementValue(4, 1)    'Date
                    sValue = oSegment.DataElementValue(4, 2)    'Time
                    Cells(4, "C") = oSegment.DataElementValue(5)    'Interchange control reference
                    sValue = oSegment.DataElementValue(6, 1)    'Recipient reference/password
                    sValue = oSegment.DataElementValue(7)     'Application reference
                End If   'sSegmentID
            End If   'sLoopSection
    
        ElseIf nArea = 1 Then
            If sLoopSection = "" Then
                If sSegmentID = "UNH" Then
                    Cells(5, "C") = oSegment.DataElementValue(1)    'Message reference number
                    sValue = oSegment.DataElementValue(2, 1)    'Message type identifier
                    sValue = oSegment.DataElementValue(2, 2)    'Message version number
                    sValue = oSegment.DataElementValue(2, 3)    'Message release number
                    sValue = oSegment.DataElementValue(2, 4)    'Controlling agency
    
                ElseIf sSegmentID = "BGM" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Document/message name, coded
                    sValue = oSegment.DataElementValue(1, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(1, 3)    'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(1, 4)    'Document/message name
                    Cells(6, "C") = oSegment.DataElementValue(2, 1)    'Document/message number
                    sValue = oSegment.DataElementValue(3)     'Document/message number
    
                ElseIf sSegmentID = "DTM" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Date/time/period qualifier
                    Cells(7, "C") = oSegment.DataElementValue(1, 2)    'Date/time/period
                    sValue = oSegment.DataElementValue(1, 3)    'Date/time/period format qualifier
    
                ElseIf sSegmentID = "TSR" Then
                    sValue = oSegment.DataElementValue(1)     'Date/time/period format qualifier
                    sValue = oSegment.DataElementValue(2, 1)    'Service requirement, coded
                    sValue = oSegment.DataElementValue(2, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(2, 3)    'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(2, 4)    'Service requirement, coded
    
                ElseIf sSegmentID = "FTX" Then
                    sValue = oSegment.DataElementValue(1)     'Service requirement, coded
                    sValue = oSegment.DataElementValue(2)     'Service requirement, coded
                    sValue = oSegment.DataElementValue(3)     'Service requirement, coded
                    Cells(8, "C") = oSegment.DataElementValue(4, 1)    'Free text
    
                ElseIf sSegmentID = "GDS" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Nature of cargo, coded
                    sValue = oSegment.DataElementValue(1, 2)    'Code list qualifier
                End If   'SegmentID
    
            ElseIf sLoopSection = "LOC" Then
                If sSegmentID = "LOC" Then
                    sValue = oSegment.DataElementValue(1)     'Place/location qualifier
                    Cells(9, "C") = oSegment.DataElementValue(2, 1)    'Place/location identification
                End If   'SegmentID
    
            ElseIf sLoopSection = "RFF" Then
                If sSegmentID = "RFF" Then
                    sQlfr = oSegment.DataElementValue(1, 1)    'Reference qualifier
                End If   'SegmentID
                If sQlfr = "BN" Then 'Booking reference number
                    Cells(10, "C") = oSegment.DataElementValue(1, 2)    'Reference number
                
                ElseIf sQlfr = "AFG" Then 'Traffic number
                    Cells(11, "C") = oSegment.DataElementValue(1, 2)    'Reference number
                
                ElseIf sQlfr = "AGT" Then 'Service group id number
                    Cells(12, "C") = oSegment.DataElementValue(1, 3)    'Reference number
                End If
                    
            ElseIf sLoopSection = "GOR" Then
                If sSegmentID = "GOR" Then
                    sValue = oSegment.DataElementValue(1)     'Transport movement, coded
                    sValue = oSegment.DataElementValue(2, 1)    'Government agency, coded
                    sValue = oSegment.DataElementValue(2, 2)    'Government involvement, coded
                    sValue = oSegment.DataElementValue(2, 3)    'Government action, coded
                End If   'SegmentID
    
            ElseIf sLoopSection = "CPI" Then
                If sSegmentID = "CPI" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Charge category, coded
                    sValue = oSegment.DataElementValue(2)     'Method of payment
                    sValue = oSegment.DataElementValue(3)     'Prepaid/collect indicator, coded
                End If   'SegmentID
    
            ElseIf sLoopSection = "TDT" Then
                If sSegmentID = "TDT" Then
                    sValue = oSegment.DataElementValue(1)     'Transport stage qualifier
                    Cells(13, "C") = oSegment.DataElementValue(2)     'Conveyance reference number
                    sValue = oSegment.DataElementValue(3, 1)    'Mode of transport, coded
                    sValue = oSegment.DataElementValue(4)     'Transport means
                    sValue = oSegment.DataElementValue(5, 1)    'Carrier identification
                    sValue = oSegment.DataElementValue(5, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(5, 3)    'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(6)     'Transit direction, coded
                    sValue = oSegment.DataElementValue(7)     'Excess transportation information
                    sValue = oSegment.DataElementValue(8, 1)    'Id. of means of transport identification
                    sValue = oSegment.DataElementValue(8, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(8, 3)    'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(8, 4)    'Id. of the means of transport
                    sValue = oSegment.DataElementValue(8, 5)    'Nationality of means of transport, coded
                End If   'SegmentID
    
            ElseIf sLoopSection = "TDT;LOC" Then
                If sSegmentID = "LOC" Then
                    sValue = oSegment.DataElementValue(1)     'Place/location qualifier
                    Cells(14, "C") = oSegment.DataElementValue(2, 1)    'Place/location identification
    
                ElseIf sSegmentID = "DTM" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Date/time/period qualifier
                    Cells(15, "C") = oSegment.DataElementValue(1, 2)    'Date/time/period
                    sValue = oSegment.DataElementValue(1, 3)    'Date/time/period format qualifier
                End If   'SegmentID
    
            ElseIf sLoopSection = "NAD" Then
                If sSegmentID = "NAD" Then
                    sNadLoopEntity = oSegment.DataElementValue(1)     'Party qualifier
                End If
                
                If sNadLoopEntity = "CZ" Then   'Consignor
                    If sSegmentID = "NAD" Then
                        Cells(16, "C") = oSegment.DataElementValue(2, 1)    'Party identification
                        Cells(17, "C") = oSegment.DataElementValue(3, 1)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 2)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 3)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 4)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 5)    'Name and address line
                    End If
                ElseIf sNadLoopEntity = "CN" Then 'Consignee
                    If sSegmentID = "NAD" Then
                        sValue = oSegment.DataElementValue(2, 1)    'Party identification
                        sValue = oSegment.DataElementValue(3, 1)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 2)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 3)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 4)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 5)    'Name and address line
                    End If
                ElseIf sNadLoopEntity = "CA" Then 'Carrier
                    If sSegmentID = "NAD" Then
                        sValue = oSegment.DataElementValue(2, 1)    'Party identification
                        sValue = oSegment.DataElementValue(3, 1)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 2)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 3)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 4)    'Name and address line
                        sValue = oSegment.DataElementValue(3, 5)    'Name and address line
                    End If
                End If   'sNadLoopEntity
    
            ElseIf sLoopSection = "NAD;CTA" Then
                If sNadLoopEntity = "CZ" Then   'Consignor
                    If sSegmentID = "CTA" Then
                        sValue = oSegment.DataElementValue(1)     'Contact function, coded
                        sValue = oSegment.DataElementValue(2, 1)    'Department or employee identification
                        Cells(18, "C") = oSegment.DataElementValue(2, 2)    'Department or employee
        
                    ElseIf sSegmentID = "COM" Then
                        Cells(19, "C") = oSegment.DataElementValue(1, 1)    'Communication number
                        sValue = oSegment.DataElementValue(1, 2)    'Communication channel qualifier
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CN" Then 'Consignee
                    If sSegmentID = "CTA" Then
                        sValue = oSegment.DataElementValue(1)     'Contact function, coded
                        sValue = oSegment.DataElementValue(2, 1)    'Department or employee identification
                        sValue = oSegment.DataElementValue(2, 2)    'Department or employee
        
                    ElseIf sSegmentID = "COM" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Communication number
                        sValue = oSegment.DataElementValue(1, 2)    'Communication channel qualifier
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CA" Then 'Carrier
                    If sSegmentID = "CTA" Then
                        sValue = oSegment.DataElementValue(1)     'Contact function, coded
                        sValue = oSegment.DataElementValue(2, 1)    'Department or employee identification
                        sValue = oSegment.DataElementValue(2, 2)    'Department or employee
        
                    ElseIf sSegmentID = "COM" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Communication number
                        sValue = oSegment.DataElementValue(1, 2)    'Communication channel qualifier
                    End If   'SegmentID
                End If   'sNadLoopEntity
    
            ElseIf sLoopSection = "NAD;DOC" Then
                If sNadLoopEntity = "CZ" Then   'Consignor
                    If sSegmentID = "DOC" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Document/message name, coded
                        sValue = oSegment.DataElementValue(2)     'Document/message details
                        sValue = oSegment.DataElementValue(3)     'Communication channel identifier, coded
                        Cells(20, "C") = oSegment.DataElementValue(4)     'Number of copies of document required
                        sValue = oSegment.DataElementValue(5)     'Number of originals of document required
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CN" Then 'Consignee
                    If sSegmentID = "DOC" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Document/message name, coded
                        sValue = oSegment.DataElementValue(2)     'Document/message details
                        sValue = oSegment.DataElementValue(3)     'Communication channel identifier, coded
                        sValue = oSegment.DataElementValue(4)     'Number of copies of document required
                        sValue = oSegment.DataElementValue(5)     'Number of originals of document required
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CA" Then 'Carrier
                    If sSegmentID = "DOC" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Document/message name, coded
                        sValue = oSegment.DataElementValue(2)     'Document/message details
                        sValue = oSegment.DataElementValue(3)     'Communication channel identifier, coded
                        sValue = oSegment.DataElementValue(4)     'Number of copies of document required
                        sValue = oSegment.DataElementValue(5)     'Number of originals of document required
                    End If   'SegmentID
                End If   'sNadLoopEntity
    
            ElseIf sLoopSection = "NAD;CPI" Then
                If sNadLoopEntity = "CZ" Then   'Consignor
                    If sSegmentID = "CPI" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Charge category, coded
                        sValue = oSegment.DataElementValue(2)     'Method of payment
                        sValue = oSegment.DataElementValue(3)     'Prepaid/collect indicator, coded
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CN" Then 'Consignee
                    If sSegmentID = "CPI" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Charge category, coded
                        sValue = oSegment.DataElementValue(2)     'Method of payment
                        sValue = oSegment.DataElementValue(3)     'Prepaid/collect indicator, coded
                    End If   'SegmentID
                    
                ElseIf sNadLoopEntity = "CA" Then 'Carrier
                    If sSegmentID = "CPI" Then
                        sValue = oSegment.DataElementValue(1, 1)    'Charge category, coded
                        sValue = oSegment.DataElementValue(2)     'Method of payment
                        sValue = oSegment.DataElementValue(3)     'Prepaid/collect indicator, coded
                    End If   'SegmentID
                End If   'sNadLoopEntity
    
            ElseIf sLoopSection = "GID" Then
                If sSegmentID = "GID" Then
                    Cells(21, "C") = oSegment.DataElementValue(1)     'Goods item number
                    sValue = oSegment.DataElementValue(2)     'Number and type of packages
                    Cells(22, "C") = oSegment.DataElementValue(3, 1)    'Number of packages
                    sValue = oSegment.DataElementValue(3, 2)    'Type of packages identification
    
                ElseIf sSegmentID = "TMP" Then
                    sValue = oSegment.DataElementValue(1)     'Type of packages identification
                    sValue = oSegment.DataElementValue(2, 1)    'Temperature setting
                    sValue = oSegment.DataElementValue(2, 2)    'Measure unit qualifier
    
                ElseIf sSegmentID = "TMD" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Movement type, coded
    
                ElseIf sSegmentID = "FTX" Then
                    sValue = oSegment.DataElementValue(1)     'Movement type, coded
                    sValue = oSegment.DataElementValue(2)     'Movement type, coded
                    sValue = oSegment.DataElementValue(3)     'Movement type, coded
                    Cells(23, "C") = oSegment.DataElementValue(4, 1)    'Free text
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;MEA" Then
                If sSegmentID = "MEA" Then
                    sValue = oSegment.DataElementValue(1)     'Measurement purpose qualifier
                    sValue = oSegment.DataElementValue(2, 1)    'Property measured, coded
                    sValue = oSegment.DataElementValue(3, 1)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(3, 2)    'Measurement value
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;RFF" Then
                If sSegmentID = "RFF" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Reference qualifier
                    sValue = oSegment.DataElementValue(1, 2)    'Reference number
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;PCI" Then
                If sSegmentID = "PCI" Then
                    sValue = oSegment.DataElementValue(1)     'Marking instructions, coded
                    Cells(24, "C") = oSegment.DataElementValue(2, 1)    'Shipping marks
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;SGP" Then
                If sSegmentID = "SGP" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Equipment identification number
                    sValue = oSegment.DataElementValue(2)     'Number of packages
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;SGP;MEA" Then
                If sSegmentID = "MEA" Then
                    sValue = oSegment.DataElementValue(1)     'Measurement purpose qualifier
                    sValue = oSegment.DataElementValue(2, 1)    'Property measured, coded
                    sValue = oSegment.DataElementValue(3, 1)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(3, 2)    'Measurement value
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;TCC" Then
                If sSegmentID = "TCC" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Freight and charges identification
                    sValue = oSegment.DataElementValue(1, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(1, 3)    'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(1, 4)    'Freight and charges
                    sValue = oSegment.DataElementValue(1, 5)    'Prepaid/collect indicator, coded
    
                ElseIf sSegmentID = "PRI" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Price qualifier
                    sValue = oSegment.DataElementValue(1, 2)    'Price
                    sValue = oSegment.DataElementValue(1, 3)    'Price type, coded
                    sValue = oSegment.DataElementValue(1, 4)    'Price type qualifier
                    sValue = oSegment.DataElementValue(1, 5)    'Unit price basis
                    sValue = oSegment.DataElementValue(1, 6)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(2)     'Measure unit qualifier
    
                ElseIf sSegmentID = "MOA" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Monetary amount type qualifier
                    sValue = oSegment.DataElementValue(1, 2)    'Monetary amount
                    sValue = oSegment.DataElementValue(1, 3)    'Currency, coded
    
                ElseIf sSegmentID = "QTY" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Quantity qualifier
                    sValue = oSegment.DataElementValue(1, 2)    'Quantity
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;DGS" Then
                If sSegmentID = "DGS" Then
                    sValue = oSegment.DataElementValue(1)     'Dangerous goods regulations, coded
                    sValue = oSegment.DataElementValue(2, 1)    'Hazard code identification
                    sValue = oSegment.DataElementValue(2, 2)    'Hazard substance/item/page number
                    sValue = oSegment.DataElementValue(3, 1)    'UNDG number
                    sValue = oSegment.DataElementValue(4, 1)    'Shipment flashpoint
                    sValue = oSegment.DataElementValue(4, 2)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(5)     'Packing group, coded
                    sValue = oSegment.DataElementValue(6)     'EMS number
                    sValue = oSegment.DataElementValue(7)     'MFAG
    
                ElseIf sSegmentID = "FTX" Then
                    sValue = oSegment.DataElementValue(1)     'MFAG
                    sValue = oSegment.DataElementValue(2)     'MFAG
                    sValue = oSegment.DataElementValue(3)     'MFAG
                    Cells(25, "C") = oSegment.DataElementValue(4, 1)    'Free text
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;DGS;CTA" Then
                If sSegmentID = "CTA" Then
                    sValue = oSegment.DataElementValue(1)     'Contact function, coded
                    sValue = oSegment.DataElementValue(2, 1)    'Department or employee identification
                    Cells(26, "C") = oSegment.DataElementValue(2, 2)    'Department or employee
    
                ElseIf sSegmentID = "COM" Then
                    Cells(27, "C") = oSegment.DataElementValue(1, 1)    'Communication number
                    sValue = oSegment.DataElementValue(1, 2)    'Communication channel qualifier
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;DGS;MEA" Then
                If sSegmentID = "MEA" Then
                    sValue = oSegment.DataElementValue(1)     'Measurement purpose qualifier
                    sValue = oSegment.DataElementValue(2, 1)    'Property measured, coded
                    sValue = oSegment.DataElementValue(3, 1)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(3, 2)    'Measurement value
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;DGS;SGP" Then
                If sSegmentID = "SGP" Then
                    sValue = oSegment.DataElementValue(1, 1)    'Equipment identification number
                    sValue = oSegment.DataElementValue(2)     'Number of packages
                End If   'SegmentID
    
            ElseIf sLoopSection = "GID;DGS;SGP;MEA" Then
                If sSegmentID = "MEA" Then
                    sValue = oSegment.DataElementValue(1)     'Measurement purpose qualifier
                    sValue = oSegment.DataElementValue(2, 1)    'Property measured, coded
                    sValue = oSegment.DataElementValue(3, 1)    'Measure unit qualifier
                    sValue = oSegment.DataElementValue(3, 2)    'Measurement value
                End If   'SegmentID
    
            ElseIf sLoopSection = "EQD" Then
                If sSegmentID = "EQD" Then
                    sValue = oSegment.DataElementValue(1)     'Equipment qualifier
                    Cells(28, "C") = oSegment.DataElementValue(2, 1)    'Equipment identification number
                    sValue = oSegment.DataElementValue(3, 1)    'Equipment size and type identification
                    sValue = oSegment.DataElementValue(3, 2)    'Code list qualifier
                    sValue = oSegment.DataElementValue(3, 3)    'Code list responsible agency, coded
    
                ElseIf sSegmentID = "TMD" Then
                    sValue = oSegment.DataElementValue(1)     'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(2)     'Code list responsible agency, coded
                    sValue = oSegment.DataElementValue(3)     'Code list responsible agency, coded
    
                ElseIf sSegmentID = "SEL" Then
                    Cells(29, "C") = oSegment.DataElementValue(1)     'Seal Number
                    sValue = oSegment.DataElementValue(2, 1)    'Sealing party, coded
                End If  'sSegmentID
            End If  'sLoopSection
        End If  'nArea
    
        'GETS THE NEXT DATA SEGMENT
        Set oSegment = oSegment.Next
    
    Loop
    
    'DESTROY OBJECTS
    Set oEdiDoc = Nothing
    Set oSchema = Nothing
    Set oSegment = Nothing

End Sub

    Click here to download a trial version of the Framework EDI