I am trying to use COM object to create a MS Word (.doc/.docx) from a MS word template. (.dotx)
The code works perfectly from the AX rich client. However fails to execute from the EP.
I have generated the proxies etc...But not sure why the same piece of code gives error from EP.
I also tried to execute the same code from AX 2012 Batches and received the same error as that of EP, so not sure whats wrong in here?
Has anyone experienced this earlier?
Appreciate your inputs.
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Method 'add' in COM object of class 'Documents' returned error code 0x800A141F (<unknown>) which means: 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.
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Stack trace: Invalid attempt to call DocuActionArchive.Add running in CIL on the client.
Error Infolog for job AVAInvoiceEngineBatch (22565691327)\Infolog for task AVAInvoiceEngineBatch (22565713471) Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException: Exception of type 'Microsoft.Dynamics.Ax.Xpp.InvalidRemoteCallException' was thrown.
at Dynamics.Ax.Application.DocuActionArchive.Add(DocuRef _docuRef, String _filename, Boolean )
at Dynamics.Ax.Application.AVAInvoiceEngine.Ava_uploadinvoice(Int32 _refTableId, Int64 _refRecId, String _refCompanyId, String _name) in AVAInvoiceEngine.AVA_UploadInvoice.xpp:line 33
at Dynamics.Ax.Application.AVAInvoiceEngineBatch.Run() in AVAInvoiceEngineBatch.run.xpp:line 22
at Dynamics.Ax.Application.BatchRun.runJobStaticCode(Int64 batchId) in BatchRun.runJobStaticCode.xpp:line 54
at Dynamics.Ax.Application.BatchRun.runJobStatic(Int64 batchId) in BatchRun.runJobStatic.xpp:line 13
at BatchRun::runJobStatic(Object )
at Microsoft.Dynamics.Ax.Xpp.ReflectionCallHelper.MakeStaticCall(Type type, String MethodName, Object parameters)
at BatchIL.taskThreadEntry(Object threadArg)
//InteropPermission perm = new InteropPermission(InteropKind::ComInterop);
filePermission = new FileIOPermission(templatePath, 'rw');
word = new COM(#Word);
documents = word.documents();
document = documents.add(templatePath);
There's a known issue with running Office x86 on Windows Server 2008 x64 and above, see this discussion about missing system profile folders.
Fantastic. Your inputs are perfectly right. After making those changes things are working all right now.
Really appreciate your help.
Is Ms Office version the same on both the EP host and the one that you use for the test job? Or is at least Ms Office 2007 installed on the EP host? Is it x86 or x64 version of Ms Office? Which Windows Server version is EP running on? Is the template file accessible from the EP host (the path should be in UNC format) under credentials used for running the EP application pool?