Works great thanks
closeMyReports = Function( {dt},
{default local},
AllmyReports = {};
myReports = Get Window List( Type( "Reports" ) );
For Each( {rep}, myReports,
Try(
myList = (rep << Xpath( "//OutlineBox" )) << get scriptable Object();
myDTs = Transform Each( {scriptableObject}, myList, If( Is Empty( scriptableObject ), ., scriptableObject << Get Data Table() ) );
If( Contains( myDTs, dt ),
Insert Into( AllmyReports, rep )
);
)
);
If( N Items( AllmyReports ) > 0,
If(
ex = New Window( "",
<<Type( "Modal Dialog" ),
<<Return Result,
V List Box( Text Box( "open reports detected.\!nOK to close them?" ), H List Box( Button Box( "OK" ), Button Box( "Cancel" ) ) )
);
ex["button"] == 1;
,
AllmyReports << close window(),
Stop()
)
);
);
dt = current data table();
closeMyReports(dt)
edit: now the script also checks for more complicated reports with many data tables.