I have to access VBA-code of Office applications from my Java application, I found THIS that says I can access VBA-code through VisualBasic DLLs using JNI. I don't want to use a COM-bridge if not necessary, I'd rather go with a DLL-solution. I created a VisualBasic Class Library in Visual Studio 2013 (a simple example to test if it works):
Public Class Test1
Public Function box()
MsgBox("boxtest!")
End Function
End Class
I built is as a release and put this in my Java project:
public class Test1 {
static{
System.loadLibrary("Test1");
}
public native void box();
}
The function is being called by new Test1().box();
.
I receive the following exception: Exception in thread "main" java.lang.UnsatisfiedLinkError: test.Test1.box()V
I also used JNA to access the DLL but after hours of trying I couldn't get it to work (I also read that it can't be used with VisualBasic DLLs). I set the Native Library Folder of my src Folder to to folder containing the DLL.
question: Can I use VisualBasic DLLs in Java, if yes, with JNA or JNI (or both) and if so what did I do wrong, how can I access the function properly? (I guess the rest with returning and parameters is easy then...)
Thank you very much in advance and merry christmas to you all! :)