-4

I want to call the one of java method of my java class file from the Microsoft docx type document?

Is there any simple and stable solution available for this ?If anybody having idea on this can you please share it with me?

Thanks in advance Yatin Baraiya

Yatin Baraiya
  • 91
  • 2
  • 15
  • What does that mean? Are you asking how to create Word addin that adds a button to the UI? – SLaks Jul 23 '13 at 13:42
  • Docx is a filetype. Could you please explain what you mean by: **I want to call the one of java method of my java class file from the Microsoft docx type document?** ? – edi9999 Jul 23 '13 at 13:44
  • 1
    I think you will have to write a COM component that's callable from word and then embed the jvm within that component and use JNI to call the java class! P.S. Just because something can be done does not mean it should be done :) – parry Jul 23 '13 at 13:53
  • Assuming you mean you want to invoke Java from Word, one way to do it would be to use IKVM to create a DLL, and to invoke that from say a VSTO Word add-in. – JasonPlutext Jul 25 '13 at 03:32
  • Have you accomplished what you need ? – edi9999 Jul 25 '13 at 16:57
  • hello i want to write the result of the java method in docx document, for that i want to only call that java method from the docx document.Let I give the simple example to you , Suppose i have one document test.docx and now i write something in that docx document which can call my java method which in test.java , suppose that method name is public String getTestData() { String data ="yatin" return data;}, so output generated document having "yatin" text in that document – Yatin Baraiya Jul 26 '13 at 07:45

3 Answers3

0

Microsoft Language for MS docx is Visual Basic, you can't natively call java methods.

Done
  • 69
  • 6
0

You could also execute a shell command to do what you want:

retValue = Shell("command", vbNormalFocus)

Found on How can I execute a shell command using VBA?

Community
  • 1
  • 1
edi9999
  • 19,701
  • 13
  • 88
  • 127
0

One way to do it would be to use IKVM to convert your Java code to a DLL, and to invoke that from say a VSTO Word add-in.

Another way would be to convert your Java code to a web service (SOAP or REST), and call that, either from a Word Add-In, or VBA (ie a Word macro). For SOAP, see for example http://jamesecampbell.blogspot.com.au/2012/11/how-to-consume-web-service-in-microsoft.html

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84