Print MSWord-Document with com4j
I'm trying to 开发者_如何学Goprint out a .doc-File with com4j. This is my Code:
document.printOut2000(true, false, WdPrintOutRange.wdPrintAllDocument, newDocumentPath, _, _, WdPrintOutItem.wdPrintDocumentContent, 1, _, WdPrintOutPages.wdPrintAllPages, true, true, _, false, 0, 0, 0, 0);
I got the values from a recorded Word-Macro and http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document.printout(v=VS.80).aspx
But all i get is the following error:
An unexpected error has been detected by Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x770f48f9, pid=3792, tid=5996
Java VM: Java HotSpot(TM) Client VM (11.0-b16 mixed mode, sharing windows-x86) Problematic frame: C [OLEAUT32.dll+0x48f9]
Any idea how i can solve this?
Edit: Com4j is opening the document, so I think the results of the previous methods aren't the problem, but thanks to DTH for the hint.
Access Violation has often to do with a memory problem, for example buffer overwrite or even a null pointer. I would suggest you to check your code again and control the results of the methods you are using to prepare the document before printing, so you can see if they are working correct.
I'm not really sure about that, but try it, maybe it's the solution to your problem.
精彩评论