0

How can I run a java class from VBA. I am trying to post to a server using Excel VBA. I can do this only with VBA on a PC but when using a MAC the DomDocument object returns a compile error. So what I did was create a java class which will post and get a response from the server. Now what I am trying to do is get the VBA to run the java class wait for a return code and process the return. If this can be done in a different language (then Java) I am also open to that. But we prefer Java.

I tried using

Dim obj as Object 
Set obj = GetObject("java:SendXML") '(sendXML is class name) 

but get a run-time error that automation failed.

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
Mohamed
  • 569
  • 1
  • 9
  • 21

2 Answers2

0

There should be no need to use Java for doing HTTP POST, you can use standard VBA libraries. See How can I send an HTTP POST request to a server from Excel using VBA?.

Edit: If you can't get the Mac answer working, I would advise using CURL which is available for lots of platforms: http://curl.haxx.se/download.html.

Community
  • 1
  • 1
artbristol
  • 31,363
  • 5
  • 65
  • 99
0

I tried a similar thing myself, but to me it appeared as if there is (almost) "no way out" of Excel 2012 for Mac. One solution I considered is to use AppleScript, there are a few examples here: http://www.rondebruin.nl/mac.htm

If you could use OpenOffice / LibreOffice you could try Obba (Java Object Handler for Excel and OpenOffice). This works for Excel on Windows too and I tried to add Mac support to Obba, but so far found no solution.

Christian Fries
  • 15,175
  • 10
  • 54
  • 65