none
Interop.Word error "Could not open macro storage" in published wcf service method

    Question

  • Hi,

    I've created the WCF service method to create a word document from template URL & published it in IIS 7.

    I'm receiving an error "Could not open macro storage" in the below code.

    Microsoft.Office.Interop.Word._ApplicationoWord = newMicrosoft.Office.Interop.Word.Application();

    Microsoft.Office.Interop.Word._DocumentoWordDoc = newMicrosoft.Office.Interop.Word.Document();

    oWord.Visible = false;

    Object oTemplatePath = templatePath;

    oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);

    Please suggest some solutions for my error. Thanks in adv!!


    Anandhan.S


    Wednesday, March 07, 2012 10:18 AM

Answers

All replies

  • Hi Anandhan.S,

    Thanks for posting in the MSDN Forum.

    As far as I know, that Office PIA doesn't recommend use on server's environment. http://support.microsoft.com/kb/257757 . A OpenXml SDK will used to create Word document. And as far as I know, there has no good way to add macro to Word document via OpenXml.

    And I will involve some experts into this issue to see whether them have good work round of it. There might be some time delay, thanks for your patience.

    Have a good day,

    Tom


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

    Friday, March 09, 2012 6:55 AM
  • Hi Anandhan,

    Tom Xu’s response is correct – unattended automation of Office products is not
    supported. He referred you to the KB article 257757. 

    Considering the error you receive there is an explanation for it in the following content:

    Microsoft Office Development with Visual Studio
    http://msdn.microsoft.com/en-us/library/aa188489(v=office.10).aspx

    Where you’ll find the following:
    When I automate Microsoft Word from ASP, I get an error that states "Could Not
    Open Macro Storage."

    You are running Word under the context of a user that does not have its registry hive
    loaded. Word requires that a "user hive" be loaded for it to run
    correctly. For more information, please see
    PRB: Error 800A175D - Could Not Open Macro Storage (Q224338).

    Use the ‘Find’ (Ctrl+F)  for the string ‘could not open macro storage’
    in the article, where you’ll see 3 references to that string.

    More content includes the following:

    Word 2010 Development | References, Code, VBA, PIA, Open XML
    | MSDN
    http://msdn.microsoft.com/en-us/office/ff972307

    How to parse VBA code and generate XML file from it [Using C#]?
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ecdf1a59-597c-41b5-806b-6ef126519c8e 

    Converting Word 2010 Documents from the DOCM to DOCX File
    Format ...
    http://msdn.microsoft.com/en-us/library/gg131933.aspx

    Regards,
    Chris Jensen
    Senior Technical Support Lead





    Chris Jensen

    Friday, March 09, 2012 8:51 PM
  • Hi,

    Thank u all for your response.

    I've resolved the error by configuring Windows Authentication in both IIS & WCF configuration.

    Component Services(DCOMCNFG) Property: Computers - My Computers - DCOM Config - Microsoft Office Word 97 - 2003 Document Properties - Identity set to Interactive user - Security, Launch & Activation Permissions added (Network Service, IIS_USRS).

    IIS Application Pool: Identity - Local System, Managed Pipeline-Integrated


    Anandhan.S

    Tuesday, March 13, 2012 1:55 PM