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
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Mohamed
  • 567
  • 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
  • 32,010
  • 5
  • 70
  • 103
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
  • 16,175
  • 10
  • 56
  • 67