-
Mar 31st, 2016, 04:06 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Running Java from VBA to use REGEX on a MAC
I have some VBA code that works fine on a PC but will not work on a MAC. This is because it makes extensive use of Regular Expressions. The code goes online, pulls track and field results, and parses the text file to populate a database. On the PC, I wrote a vb.net console application that takes in the Pattern and String as arguments and returns the result as a long string to the standard output. I then call the .exe according to a method I found here:
http://www.vbforums.com/showthread.p...Capture-Output
Here is my code:
Code:
Function MyRegex(ByVal MyPattern as String, ByVal MyString as String) as String
Dim cls As New clsRunApp
Dim s as String
cls.Command = ActiveWorkbook.path & "\bin\RegexHood.exe "
cls.AddParamater MyPattern & "$" & MyString
s = cls.RunAppWait_CaptureOutput
Set cls = Nothing
End Function
This works fine.
My hope is that a simple fix is to re-write the code in JAVA instead. This way, my VBA can run on both platforms. I tested the JAVA code and it works fine. The command that I need to send is, for example:
java RegexHood \d*$VBforums Rocks1234
it returns 1234
I tried to call it using the following modified code:
Code:
Function MyRegex(ByVal MyPattern as String, ByVal MyString as String) as String
Dim cls As New clsRunApp
Dim s as String
cls.Command = "java.exe " ' JAVA is in my PATH
cls.AddParamater ActiveWorkbook.path & "\RegexHood " & MyPattern & "$" & MyString
s = cls.RunAppWait_CaptureOutput
Set cls = Nothing
End Function
Unfortunately, the code returns a "Cannot find file" error. I tried a few combinations like:
cls.Command = ActiveWorkbook.path & "\java.exe RegexHood " & MyPattern & "$" & MyString
(and do not add any parameters)
Thanks in advance for any assistance.
Adrian
Last edited by adrian1906; Mar 31st, 2016 at 04:12 PM.
-
Mar 31st, 2016, 08:14 PM
#2
Thread Starter
Addicted Member
Re: Running Java from VBA to use REGEX on a MAC
Update.
According to this thread:
http://stackoverflow.com/questions/8...rom-vba-on-mac
Even if I could run Java from VBA on a PC, I would not be able to duplicate the action on the MAC as easily.
Looks like I may have to convert my VBA code to JAVA...which may not be a bad idea in the long run. A quick Google search seems to indicate that there are ways for Java to read and write excel files.
Thanks to all that chimed in to help.
Adrian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|