VBA Shell Java调用错误 [英] vba shell java call errors

查看:87
本文介绍了VBA Shell Java调用错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS Access公共功能中,我使用外壳程序调用来运行java xslt模块:

In an MS Access public function, I run a java xslt module using a shell call:

Set shell = CreateObject("WScript.Shell")
cmd = "java -jar D:\saxon9he.jar -s:D:\input.xml -xsl:D:\transf.xslt -o:D:\output.xml"
Set objExecObject = shell.Exec(cmd)

我捕获了以下错误:

就像在另一个MS Access实例中一样,我必须在某个地方引用环境变量(其中一个是JAVA_HOME,它已设置为C:\Program Files\Java\jdk1.5.0_16\bin).
但是我可以在MS Access中的哪个位置设置该引用?
还是此错误是由其他原因引起的?
例如,MS Access/VBA在USER和/或SYSTEM中访问环境变量PATH可能会遇到问题吗?在我的设置中,是用户环境参数PATH保存有关java.exe位置的信息.

As exactly the same worked fine in another MS Access instance, I assume I have to refer to an environment variable somewhere (one of these is JAVA_HOME which has been set to C:\Program Files\Java\jdk1.5.0_16\bin).
But where in MS Access can I set that reference?
Or is this error caused by something else?
Might there for instance be trouble with MS Access / VBA accessing the environment variable PATH in USER and/or SYSTEM? In my setup, it's the user environment paramater PATH that holds the information on the location of java.exe.

推荐答案

我在命令中添加了内容,如下所示:

I added stuff to the command to be executed as follows:

Set shell = CreateObject("WScript.Shell")
Dim JavaHome As String
JavaHome = shell.Environment("USER")("JAVA_HOME") & "\"
cmd = JavaHome & "java -jar D:\saxon9he.jar -s:D:\input.xml -xsl:D:\transf.xslt -o:D:\output.xml"
Set objExecObject = shell.Exec(cmd)

这很好,因为我现在自己提供了java.exe的路径.

This works fine, as I now supply the path to java.exe myself.

但是我仍然想知道,为什么突然之间MSA/VBA无法再从用户环境(包括;%JAVA_HOME%;)中应用PATH参数...

But I still wonder, why all of a sudden MSA/VBA could not apply the PATH parameter from user environment (which includes ;%JAVA_HOME%;) any more...

我将为该问题创建另一个线程...

I will create another thread for that question...

这篇关于VBA Shell Java调用错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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