You need a reference to the instance of the w_calling window you wish to close.
If the OpenSheetWithParm for the instance of the w_called window is being called from the w_calling window, then include a reference in the parameters structure that is passed into w_called:
params.calling_window = This
OpenSheetWithParm(w_1,param,w_main,0,Original!)
Next, in w_called, save the reference to the calling window in an instance variable:
window iw_calling // A generic window reference is adequate unless you want to access methods or public properties specific to w_calling, in which case you would declare as:
w_calling iw_calling
Then, in the Open event of w_called:
iw_calling = params.calling_window
Finally, when you wish to close the instance of w_calling,
If IsValid(iw_calling) Then
Close(iw_calling)
End If
If you do not or cannot pass a reference to the instance of w_calling in to the w_called window, it's a little more complicated. You can use the GetFirstSheet() and GetNextSheet() PowerScript functions to obtain a reference to all sheet windows, one at a time. See the Help topics on each for more information. Always use IsValid() to ensure the reference you obtain is valid, then check each window's class name using the ClassName() method to see if it is a window of type w_calling. Once you find it, use the Close() PowerScript command.
Note that if there can be multiple sheet windows of type w_calling open simultaneously, this technique will NOT identify the one instance that opened w_called... in which case you really need to pass the reference to w_calling in to w_called via the parameters structure.
Regards,
John