Depending on the nature of the programs you can look at bypassing VB and using some of the Win32 extensions to do the job. It really depends on what you need to do. A very good place to start is Win32 Perl Programming by Dave Roth from New Riders. This is available at Oreilly's Safari and can show you the basics of bypassing VB or working in tandem with Excel and Access using the OLE/COM interfaces. Also check out the Win32 code library 14831 there are some programs in there that could be converted to what you need. But again it depends on what you are doing you may not need to use both VB and Perl but only Perl.
Some good jump points for Win32 perl:
I think to sum up my ramble, think of it the other way around. Don't use vb to call perl but use perl to access the vba applications. It sounds like you would want to explore Win32::OLE to do this.
"No matter where you go, there you are." BB
| [reply] |
Theres a much better way to do this. Assuming you have ActiveState Perl installed.. It installs a Perl Scripting thingy, which works similarly to VBscript and JScript etc, you can access this inside VB (or other windows apps), using the Microsoft Scripting Control. Just load the control, set the appropriate Language type ('PerlScript' I think, else look in the AS docs'), and add perl code to it - Nifty!
An article about using the Scripting Control (plus link where you can get the Scripting Control from)
(I knew this was possible, just had to look around some to find out how..)
BTW: theres also PerlCOM, to call perl using COM objects, but thats part of the AS stuff you actually have to pay for :)
C. | [reply] |
What is best suited to your application depends on the type of interaction b/w Visual Basic and Perl, as well as the kind of tasks you want to perform in Perl.
If you only want to call the Perl script from VB with simple data as command-line parameters, then have a look at the solution, node 312989, I proposed for a similar node (New Pseudo Language). In this solution, the VB application calls the Perl script and pass the variables as command-line parameters.
And if you have more complicated data, then you could consider saving the data to be passed in a file from VB, and read it from Perl.
There are lots of options available. It would be more useful if you could describe what kind of task you want the Perl script to perform, what kind of data you want the VB program to pass to the perl script, etc.
| [reply] |
Firstly, if you want to call perl scripts from vb, just use system calls and either use return values or text files as a simple way to pass data back and forth.
It may be worth your time to review Activestate's Guide to Using OLE with Perl. This document gives specifics on how to use Win32 OLE within perl to manipulate Excel, among other things. These techniques might allow you to remove the need for a VB application entirely, depending on the amount of user interaction your program requires.
If it is possible for you to remove Visual Basic from the scene altogether, you can use the advice under How do I convert a VBA macro to Perl? to hack together a script that will help (but not perform a 'total' conversion) convert VB code to perl.
| [reply] |
Thanks for all your help... Put up a post go to bed then there is all these lovely answers... Lots of leads to follow thanks.
I am afraid I am stuck using VB. We are developing in-house tools in Excel for Scientist to use the hydrological data from our database. They are familiar with Excel. Also VB is the language that ArcGIS uses (esri's GIS).. As I have gotten older I have found that it is much easier to go with the flow and there are many other pieces of VB code that do similar stuff..
That said I would really like to be able to call Perl scripts I have written from VB occasionally... But I have been completely stumped how I could do this.. But know I have some places to look thanks..
| [reply] |
A late response... but here is what worked for me:
Dim RetVal
RetVal = Shell("C:\Perl\bin\perl.exe C:\BBMM.pl", 1)
| [reply] |