You need to extend your export-loops to a further information from which application a certain object comes from and check this within additional if-loops within the routine and open and close those applications appropriate. It's not mega-complicated but you will need some hours to get to logic right. Maybe it's easier to export everything separately and match those parts afterwards. Also an alternatively might be to creating one for this reason specialized qvw which contained all those objects.