There is a solution for the managed application mode. You can use GetWindows() function to enumerate the opened windows and then check in some way if this window contains the printed form. For example you can add a caption part “PrintedForm” for all windows with printed forms.
The part of the printed form generation code:
Spreadsheet = New SpreadsheetDocument;
The command to handle opened windows:
OpenedWindows = GetWindows();
For Each Window In OpenedWindows Do
WindowCaption = Left(Window.Caption, 11);
If WindowCaption = "PrintedForm" Then
// Your code here
This won't work in the Ordinary Application mode.