none
Word 2010 automation document open fails when template directories are on a network drive. RRS feed

  • Question

  • ·         We have 3rd party application that does not work since our upgrade to Office 2010. I have nailed down the problem to when a document is being opened via automation when the user's workgroup template directory or user template directory are on a network drive. I've written a VB test app that reproduces the problem...

    Private Sub btnTryCatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTryCatch.Click
      Dim app As New Word.Application
    
      Try
        Dim doc As Word.Document
        doc = app.Documents.Open("c:\test\test1.docx")
        Debug.WriteLine("no chars in doc: " & doc.Characters.Count.ToString)
        doc.Close(False)
        NAR(doc)
        GC.Collect()
        GC.WaitForPendingFinalizers()
      Catch ex As Exception
        Debug.WriteLine(ex.ToString)
      Finally
        Debug.WriteLine("Finished")
        app.Quit()
        NAR(app)
        GC.Collect()
        GC.WaitForPendingFinalizers()
      End Try
    End Sub
    Private Sub NAR(ByVal o As Object)
      Try
        System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
      Catch
      Finally
        o = Nothing
      End Try
    End Sub

    With network based template directories I get a System.Runtime.InteropServices.COMException (0x800A1066): Command failed (randomly, sometimes it works)

    With local template directories it works every time.

    (Word Options - Advanced - File Locations - user templates/workgroup templates)

    Any ideas?

    Many thanks.

    John.

    Thursday, February 3, 2011 2:37 PM

All replies

  • I have a related (if not the same) issue:

    With Macro Security set to "Disable with Notification," Word 2010 users cannot enable macro security for DOCX documents they've created based on DOT nor DOTM files, nor DOC files based on DOTM files. If they create a DOC document from a DOT template, then they will be prompted and can enable macros.

    Word 2007 doesn't have this problem; it lets users enable macros even if the base template is on the server, and whether or not it is DOT or DOTM, DOC or DOCX.

    This is a significant problem for users that keep macro-enabled templates in the Workgroup Templates path.

    When will this be fixed?

    Friday, February 11, 2011 9:06 PM
  • Hi RHG,

    Thanks for posting in the MSDN Forum.

    As far as I know, the 0x800A1006 Exception is a security problem. Would you do some trouble shoot after review the references: http://msdn.microsoft.com/en-us/library/bb772087.aspx?appId=Dev10IDEF1&l=EN-US&k=k(WORDTEMPLATE1.GLOBALS.RIBBONS);k(VST.PROJECTITEM.WORDDOCUMENT);k(TargetFrameworkMoniker- , http://msdn.microsoft.com/en-us/library/aa188311(v=office.10).aspx .

    I hope it helps.

    Have a great day,

    Tom Xu


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 17, 2011 9:12 AM
    Moderator
  • Hello,

    We have exactly the same problem with Word 2010 automation as John Russell has.

    From other posts we have seen the two solutions:

    1) retry the app.Documents.Open until it succeds (with a sleep(500) inbetween)

    2) Wait for a given time between the app creation and the app.Documents.Open.

    The necessary time for case 2) depends on the following operation with the document.

    Displaying the document requires 1 second and printing the document requires 3 seconds, otherwise error 80010001 may occur.

    We have not thoroughly tested the first case yet.

    We would like no know what causes this strange behavior.

    Is this a Word 2010 automation bug or what else?

    We have hundreds of customers running Word macros every day and would like to get a feedback what's going on with this problem

    Thanks and greetings Marcel

     

    Friday, April 15, 2011 3:52 PM
  • Hello,
    Tom Xu is talking about the 0x800A1006 Exception which may be a security problem but John and me observed the exception 800A1066.
    Tom, do you think this is a security exception and why would the exception be avoided when you insert wait times or retries as described in my first post a week ago?
    Now we have also thoroughly tested the first solution and it works fine.
    We had to insert some more wait times before further operations take place with the word document object.
    For example we have to wait two seconds before we can read the word document object.MailMerge.State.
    Generally on faster PCs word automation runs less relaible than on faster PCs.
    A third solution would be to copy the user's workgroup template directory and user template directory to a local drive and also modify the word registry settings for the user's workgroup template directory and user template directory to the local drive and set them back after word automation is finished.
    Thanks and greetings Marcel
    Thursday, April 21, 2011 3:56 PM
  • Creating a wait time between app creation and the app.Documents.Open was the solution for us.   Using WScript.Sleep we enforce a 100ms wait fixed the problem for us.  Prior to that we were experiencing the 800A1066 error.  It was somewhat intermittent across all platforms, but very consistent in our Citrix environment.  I'm assuming the faster processors were the difference.

    Friday, August 12, 2011 4:46 PM
  • We experienced a similar problem and found that applying KB2553912 should fix the issue.

    http://support.microsoft.com/kb/2553912

    Please visit http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=2553912&kbln=en-us to download the hotfix.

    • Proposed as answer by Haastastic Thursday, September 8, 2011 5:35 PM
    Thursday, August 18, 2011 10:20 PM
  • Hello,

     

    we have also the same problems with Word 2010 and Folder Redirection in Win7 - if we open a template or word document it fails every second time...

    if we delete the Normal.dotm it wordk but word recreates the Normal.dotm and we also need that file - for me it looks like to be a bug...

    but we need a solution/workaround - please help...

    Maybe it is important: we use KMS to license our Office 2010 - I have read in other posts that mybe this can cause the problem??

    robert



    applying KB2553912 fix the issue. http://support.microsoft.com/kb/2553912
    • Edited by Mad Rian Wednesday, November 16, 2011 4:48 PM
    Wednesday, November 16, 2011 6:50 AM