I need a way to convert a word document into a PDF file, in AX.
And I found this bit of code that works when i run it on the client, but fails when run on server.
private void Word2Pdf(Filename _fileName, fileName _newFile)
{ COM wordApplication; COM wordDocuments; COM wordDocument; COM wordRange; try { new InteropPermission(InteropKind::ComInterop).assert(); wordApplication = new COM("word.application"); wordApplication.visible(TRUE); wordDocuments = wordApplication.Documents(); wordDocument = wordDocuments.add(_fileName); wordDocument.saveas(_newFile,17); wordDocument.saved(true); wordDocument.close(); wordApplication.quit(); } catch { throw error("Unknown ClrError"); } }
I get this error when this code runs on server:
Method 'add' in COM object of class 'Documents' returned error code 0x800A13E9 (<unknown>) which means: Error found in word.
Does anyone know how to fix this, or perhaps someone has another way to convert word to pdf.
*This post is locked for comments