none
Windows Servis Error RRS feed

  • Question

  • Hello,
    Create Windows Service.
    Service returns the number of word documents that are open on the computer.
    But this code gives an error. But this code, not error by c# form authantication. 

     Application winObj = (Application)Marshal.GetActiveObject("Word.Application");
    foreach (var item in winObj.Documents)
    {
               count++;
    }

    (HRESULT özel durum döndürdü: 0x800401E3 (MK_E_UNAVAILABLE))

    this error.


    1905

    Tuesday, November 13, 2018 6:01 AM

All replies

  • Hi Özlem,

    I tested your code and it was a success on my machine. Could you provide more detailed information? For example, error messages(English). 

    You could use the following code to get the number of open Word documents:
    Microsoft.Office.Interop.Word.Application WordObj;
    WordObj = (Microsoft.Office.Interop.Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
    // The count variable is the number of open Word documents
    int count = WordObj.Windows.Count;

    You could refer to the following  link:
    C# Get list of opened Word documents

    Best Regards,

    Bruce

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, November 13, 2018 10:09 AM
    Moderator