none
VBRuntime error occurs (This command is not available as no document is open) when MyPluggin is enabled RRS feed

  • Question

  • Hi,

    I have created a plugin for MicrosoftWord 2010 which extract all the texts from open document and do some processing and highlights some of the words in the open document.

    The pluggin is working fine in almost every machine but in one of the machine i am facing a wierd issue.In this machine there wont be any default document or active document opened at the start of Word application.

    I am explaining the issue below,

    1. User opens MS Word.
    2. Word’s default open document is automatically closed (as discussed, to enforce DMS(Document Management System) use)
    3. User closes MS Word (clicks red ‘x’ as normal)

    *VBRuntime error occurs (This command is not available as no document is open)

    1. User dismisses error by clicking ‘End’
    2. MS Word closes

    I have put debugging Message boxes in every Word event to find at which point the VR error comes in that machine, After running through this with the debug version of My Pluggin installed following the steps above:

    • (During step 1) All functions listed during Word open & load are displayed as expected.
    • (During step 2) When the document is auto closed the alert “Connect: OnDocumentBeforeClose()” is shown
    • (During step 3) before any further debug prompts, the VB error appears (This command is not available as no document is open)
    • (Step 4) Clicking ‘end’ on the error then continues to “Connect: OnBeginShutdown()” and subsequent functions until.
    • (Step 5) MS Word closes

    Hope this helps pinpoint the code that produces the error

    It is also the case that:

    Word Open à Close = VB error

    Word Open à Create new local doc à Close = VB Error

    Word Open à Open existing local doc à Close = VB Error

    Word Open à Create new DMS doc à Close = VB Error

    Word Open à Open existing DMS doc à Close = *No Error

    I don’t know the relevance of opening an existing DMS doc but it obviously gives some handle or fulfils whatever criteria it is that My Pluggin is looking for.

    Please someone help me out to solve this Issue, Thanks in advance.

    Regards, Chetan.

    Wednesday, November 21, 2012 10:21 AM

Answers

  • Hi Tom,

    Thanks for the Reply.

    I am able to resolve this issue by Releasing the instance of WordApp in 'DocumentBeforeClose' Event. Code below solved the issue.

    m_pWordApp->Release();

    Thanks and Regards,Chetan.


    Chetan Rajakumar

    Monday, November 26, 2012 7:36 AM

All replies

  • Hi Chetan,

    Thanks for posting in the MSDN Forum.

    It's based on my experience that will make more sense if you can provide your add-in's code for further research. I suppose you attempt access the Document instance after document has been closed. I think it can be avoid this case in your code via some conditional statement.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 22, 2012 2:07 AM
    Moderator
  • Hi Tom,

    Thanks for the Reply.

    I am able to resolve this issue by Releasing the instance of WordApp in 'DocumentBeforeClose' Event. Code below solved the issue.

    m_pWordApp->Release();

    Thanks and Regards,Chetan.


    Chetan Rajakumar

    Monday, November 26, 2012 7:36 AM