Попробуйте при открытом и закрытом документе (я тестировал writer-ом)
- Код: Выделить всё
program test;
{$APPTYPE CONSOLE}
uses
SysUtils, Variants
,uno_pascal_helper;
var
xComponentContext
,ServiceManager
,DesktopService
,XDesktop
,CurComp
: Variant;
begin
Bootstrap(xComponentContext);
ServiceManager := xComponentContext.getServiceManager;
DesktopService := ServiceManager.createInstanceWithContext( 'com.sun.star.frame.Desktop', xComponentContext );
XDesktop := UNOQueryInterface(DesktopService, 'com.sun.star.frame.XDesktop');
CurComp := XDesktop.getCurrentComponent;
if VarIsClear(CurComp)
then WriteLn('Can not get CurrentComponent')
else WriteLn('CurrentComponent was received');
end.