That was the reason why I recommended calculating your file export on the fly.
Some things can be done via menu items, but also procedurally. Statements are used in procedures.
Read about the filesave statement in the Pan 6 Help > Programmer's Reference.
Also about the variations of the lookup( function, specially lookupall(.