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

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

问题描述

有jar库

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

native C++ port is not yet available (as DLL)

我需要打电话

我有 3 种可能性:

1) 等到本地端口准备好2)通过brigde(?)从VB使用JAR库,需要安装JRE3) 使用 GCJ 将 JAR 编译成原生 DLL 并使用它形成 VBA

1) Wait until native port is ready 2) Use JAR library from VB via brigde (?), installed JRE required 3) Compile JAR into native DLL using GCJ and use it form VBA

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

我认为:位置1 很容易,但我必须等待位置3 在实践中是不可能的

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

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

Is there some ideas about pos. 2?

谢谢.

推荐答案

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

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>)

如果你确实需要返回一个值,那么你很可能需要一个桥接器——这里有类似的讨论(对于 VB.NET,但原理是一样的):你可以在 VB.net 程序中使用 Java 库吗?

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?

基于人们创建的大多数桥梁都是为 .NET 而不是 VBA/6,因此您可能需要以某种方式创建自己的桥梁,或者创建一个 .NET DLL,然后由您的 VBA 代码使用.

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天全站免登陆