Close document from background session

Hi!

The previous version I used the follow rows worked correctly:

VARIANT_BOOL b_not = VARIANT_FALSE;
swApp->put_UserControl(b_not);
swApp->put_Visible(b_not);

//opening: swApp->OpenDoc6(...)

hres = swApp->CloseDoc(FileName);

And I get a SW drop a exception:
The instruction at "0x3d063281" referenced memory at "0x00000060".
The memory could not be "read".

Why???

Thanks!
Regard:
ZsZs.

PS:
I use SW Professional 2009 x64 Edition SP3.0
C++ / COM
SolidworksApi macros