When using the formula in an embedded view, no document is selected.
Solution:
Use a button with these formulas:
@Command([OpenView];"view_name");
@Command([ViewCollapseAll]);
@Command([ViewExpand]);
@Command([EditSelectAll]);
@Command([FileCloseWindow]);
@Command([ToolsRunMacro];"(dummy_agent_name)")
Posted on Notes Forum.