Quote plugin RRS feed

  • Question

  • Hi,

    When  try to run the following code:

     Word.Application WdApp = new Application();

                // Create new document from the template
                object Template = (object)QuoteTemplatePath;
                object newTemplate = (object)false;
                object doctype = (object)(Word.WdNewDocumentType.wdNewBlankDocument);
                object visible = (object)false;

                Word.Document quoteDoc = WdApp.Documents.Add(ref Template, ref newTemplate, ref doctype, ref visible);

    I get the following error in a CRM 2011 Plugin:

    System.Runtime.InteropServices.COMException was unhandled by user code
      HelpLink=C:\Program Files (x86)\Microsoft Office\Office12\1033\WDMAIN11.CHM#24631
      Message=Word was unable to read this document.  It may be corrupt.
    Try one or more of the following:
    * Open and Repair the file.
    * Open the file with the Text Recovery converter.
      Source=Microsoft Word
           at Microsoft.Office.Interop.Word.Documents.Add(Object& Template, Object& NewTemplate, Object& DocumentType, Object& Visible)
           at IDX_Quote_Plugin.Engine.GenerateWordQuote(IOrganizationService service, Entity quote)
           at IDX_Quote_Plugin.IDXQuoteGeneratePlugin.Execute(IServiceProvider serviceProvider)
           at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
           at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)

    Any help is greatly appreciated.



    Wednesday, February 8, 2012 6:53 AM

All replies