WordBasic MailMerge AppClose Please Help

Can Anyone Help.

I am writing an app which uses word basic to perform a mail merge and send
the
resulting docouments to an email address. This works fine, but i am having
trouble closing word
It say that the docoument is still in the process of sending an email.

Is there a way to see if word is no-longer busy and close the application
safely.

Here is an extract of some of my code.

        MSWord = Variant::CreateObject("Word.Basic");
        MSWord.Exec(Procedure("AppShow"));

MSWord.Exec(Procedure("ChDir")<<m_szWordDocoumentTemplatePath.c_str());
        MSWord.Exec(Procedure("FileOpen")
<<m_szWordDocoumentTemplateName.c_str());
        MSWord.Exec(Procedure("MailMergeOpenDataSource")
<<m_szDocumentTemplateDataSourceName.c_str());

MSWord.Exec(Procedure("MailMerge")<<2<<(int)m_Target<<1<<iIndex<<iBatch);
                     MSWord.Exec(Procedure("MailMergeToPrinter"));

    MSWord.Exec(Procedure("FileClose")<<2);

    MSWord.Exec(Procedure("AppClose"));

Many Thanks

Surjit.
suritj.sam...@{*word*269}.net