从VBA/VBScript/Visual Basic Classic调用Java库(JAR) [英] Calling Java library (JAR) from VBA/VBScript/Visual Basic Classic

查看:576
本文介绍了从VBA/VBScript/Visual Basic Classic调用Java库(JAR)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有jar库

本地C ++端口尚不可用(作为DLL)

我需要打电话给

我有3种可能性:

1)等到本机端口准备好 2)通过brigde(?)使用来自VB的JAR库,需要安装JRE 3)使用GCJ将JAR编译为本地DLL,并以VBA形式使用

http://www.microsoft.com/germany/msdn/library/office/OfficeVBAUndDieWindowsAPI.mspx?mfr=true

我认为: 位置1很简单,但我必须等待 位置3实际上是不可能的

是否有关于pos的一些想法. 2?

谢谢.

解决方案

这取决于您是否要从JAR文件中返回值.如果您不这样做,而只希望执行一个方法,则可以使用VB中的"Shell"(或ShellExecute),如下所示:

Shell("java.exe -jar " & <yourJARFile>)

如果您确实需要返回一个值,那么您很有可能需要一个桥梁-此处类似的讨论(对于VB.NET,但原理相同):http://www.microsoft.com/germany/msdn/library/office/OfficeVBAUndDieWindowsAPI.mspx?mfr=true

I think: pos. 1 is easy, but I must wait pos. 3 is in practice impossible

Is there some ideas about pos. 2?

Thanks.

解决方案

It depends on whether you wish to return values from the JAR file or not. If you do not, and just wish to execute a method then you can use a "Shell" (or ShellExecute) from VB as follows:

Shell("java.exe -jar " & <yourJARFile>)

If you do need to return a value then you will more than likely need a bridge - similar discussion here (for VB.NET, but principle is the same): Can you use Java libraries in a VB.net program?

Based on that most bridges that people have created are for .NET and not for VBA/6 so you would maybe need to create your own somehow, or perhaps create a .NET DLL that is then consumed by your VBA code.

这篇关于从VBA/VBScript/Visual Basic Classic调用Java库(JAR)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆