How to execute Visual Basic from JAVA ? – part 2 – autostart your VB…


In our last article we have seen how to start word from JAVA. Now we will start word with a document in parameter and then we will put an autoopen marcro in our document.

JAVA – Code

String sCmd ;

sCmd = “C:\\Program Files\\Microsoft Office\\OFFICE11\\winword.exe ” + “\”c:\\Mes documents\\Doc3.doc\”” ;

try {
Runtime.getRuntime().exec(sCmd);
} catch (IOException e) {
e.printStackTrace();
}

This will start word with a special document.

The next step is how to autostart the VB code.

You can put in your document macro the autoopen, which will automatically starts when the document is launch

VB – Code in the document

Sub autoopen()

Load UserForm1
UserForm1.Show

End Sub

Ok, this is a simple way to starts VB from JAVA. Of course you can’t synchronise your programs and also you can’t pass parameters. This is not a perfect integration but it can helps you to reuse easily something which exists already on your system.
Of course it breaks the main advantage of JAVA to be multi-system, but the world isn’t perfect… for now.

Greetings.

Advertisements

About pierrekoerber
Hey, pour faire connaissance, laisse-moi un message... drop me a line.

2 Responses to How to execute Visual Basic from JAVA ? – part 2 – autostart your VB…

  1. Hi Pierre,

    you can write a wrapper in C/C++ to bridge Java with a VB DLL.

    Java C/C++ bridge your wrapper in C/C++ (DLL) C/C++ bridge VB

    IMHO, Java and VB can access to a C/C++ apps without additions.

  2. My previous comment was altered by wordpress…

    second line is something like that :

    Java [link to] C/C++ bridge [link to] your wrapper in C/C++ (DLL) [link to] C/C++ bridge [link to] VB

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: