Copy invoice from AR_InvoiceHistory to flat file

SUGGESTED

I have most of this script working but am hung up on the part reading from the line detail object.  I have created a button on the AR Invoice History Inquiry panel so that the end user can find the invoice they want to copy, press the button, and the flat file will be generated.  This part of the script works fine (getting the header variables):

if oSession.UI<>0 Then

    Set oUI = oSession.AsObject (oSession.UI)

End If

retVal = oBusObj.GetValue ("InvoiceNo$", invoice_number)

retVal = oBusObj.GetValue ("InvoiceDate$", invoice_date)

retVal = oBusObj.GetValue ("CustomerNo$", customer_number)

And so on.........  But, when I try to get the line detail, here is my script:

Set oLines = oBusObj.AsObject (oBusObj.Lines)

retVal = oLines.MoveFirst()

Do until oLines.EOF

    retVal = oLines.GetValue ("DetailSeqNo$", line_number)

    retVal = oLines.GetValue ("ItemCode$", item_code)

The script fails at the Set oLines = oBusObj.AsObject (oBusObj.Lines), saying "Wrong number of arguments or invalid property assignment: 'oBusObj.Lines'

Evidently, that fails to open the detail object but I don't know the syntax to do it correctly.

Any help?