Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. COMException while opening MS-Word files using APIs

COMException while opening MS-Word files using APIs

Scheduled Pinned Locked Moved C#
helpcomsysadminwindows-adminjson
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abhishek Joshi
    wrote on last edited by
    #1

    Hi, I am facing problem of COMException while opening MS-Word files on
    Windows Server 2003. I am refering Interop.Word.dll for opening MS-Word files to count the
    number of words from it. I am using following API to open the doc files.

    Word.ApplicationClass wordApp = null;
    Word.Document aDoc = null;
    aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible,
    ref missing, ref missing, ref missing, ref missing);
    aDoc.Activate();

    If I deploy above code on
    Windows 2000 professional then it works without error but if I deploy same code on Windows Server 2003 then I get following exception.

    System.Runtime.InteropServices.COMException (0x800A1066): Command failed at
    Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles,
    Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument,
    Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible,
    Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)

    Is there is other way to overcome this bug? -- modified at 2:41 Saturday 19th May, 2007

    #Abhi#

    M M 2 Replies Last reply
    0
    • A Abhishek Joshi

      Hi, I am facing problem of COMException while opening MS-Word files on
      Windows Server 2003. I am refering Interop.Word.dll for opening MS-Word files to count the
      number of words from it. I am using following API to open the doc files.

      Word.ApplicationClass wordApp = null;
      Word.Document aDoc = null;
      aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing,
      ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible,
      ref missing, ref missing, ref missing, ref missing);
      aDoc.Activate();

      If I deploy above code on
      Windows 2000 professional then it works without error but if I deploy same code on Windows Server 2003 then I get following exception.

      System.Runtime.InteropServices.COMException (0x800A1066): Command failed at
      Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles,
      Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument,
      Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible,
      Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)

      Is there is other way to overcome this bug? -- modified at 2:41 Saturday 19th May, 2007

      #Abhi#

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! Do you have the same version of Word installed on both machines? (or rather 3 machines: The development machine that created Interop.Word.dll plays a role, too)

      Regards, mav -- Black holes are the places where God divided by 0...

      A 1 Reply Last reply
      0
      • M mav northwind

        Hi! Do you have the same version of Word installed on both machines? (or rather 3 machines: The development machine that created Interop.Word.dll plays a role, too)

        Regards, mav -- Black holes are the places where God divided by 0...

        A Offline
        A Offline
        Abhishek Joshi
        wrote on last edited by
        #3

        Hi, Thanks for reply. I have same version of Word installed that is Word 2003. Just OS are different.

        Abhishek J

        1 Reply Last reply
        0
        • A Abhishek Joshi

          Hi, I am facing problem of COMException while opening MS-Word files on
          Windows Server 2003. I am refering Interop.Word.dll for opening MS-Word files to count the
          number of words from it. I am using following API to open the doc files.

          Word.ApplicationClass wordApp = null;
          Word.Document aDoc = null;
          aDoc = wordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref missing, ref missing, ref missing,
          ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible,
          ref missing, ref missing, ref missing, ref missing);
          aDoc.Activate();

          If I deploy above code on
          Windows 2000 professional then it works without error but if I deploy same code on Windows Server 2003 then I get following exception.

          System.Runtime.InteropServices.COMException (0x800A1066): Command failed at
          Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles,
          Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument,
          Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible,
          Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)

          Is there is other way to overcome this bug? -- modified at 2:41 Saturday 19th May, 2007

          #Abhi#

          M Offline
          M Offline
          Manoj Kumar Rai
          wrote on last edited by
          #4

          Hi First create the Instance of the application using "new".

          Manoj Never Give up

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups