我想在excel中使用vb脚本调用一个java jar文件。我的文件格式是“xlsm”,我的 vb 脚本代码在哪里。
当我执行我的代码时,控制台来来去去,我不写控制台上的内容。请看一下代码
Public Function RunProgram( _
program As String, _
Optional command As String = "" _
) As WshExec
Dim wsh As New WshShell
Dim exec As WshExec
Dim oShell
Application.ScreenUpdating = False
Set exec = wsh.exec(program)
Call exec.StdIn.WriteLine(command)
Set RunProgram = exec
'Application.ScreenUpdating = True
End Function
Public Function evenOdd1(Number As Double) As Double
Call Run
End Function
Public Sub Run()
Dim program As WshExec
Set program = RunProgram("java -jar G:\\excel\\MyTest.jar""Margus")
'Debug.Print "STDOUT: " & program.StdOut.ReadAll
End Sub
我试过 Application.ScreenUpdating, Application.visible 来保持屏幕但无法保持控制台..请帮助我