On 4/27/2011 11:06, Devon McCormick wrote:
> Members of the Forum -
>
> Although I agree with this sentiment (from
> http://www.jsoftware.com/jwiki/Articles/JExcel):
>
>     "Don't you find it maddening when you have to use another tool, at rare
> intervals, and you have to re-learn its inconsistencies? I do, so when I use
> Excel, I try to use the bare minimum of Excel facilities, whether or not it
> would be better to use more VBA and less J."
>
> There sometimes comes a time when one is forced to do the nasty and deal
> with VBA.  So, in order to avoid modifying someone else's C++ code, I'd like
> to replace that code with some J.  However, to do this, I need to load data
> into a spreadsheet, then run a VBA macro from within J.  I know how to load
> the data (using either Tara or OLEExcel) but not how to invoke an arbitrary
> macro.  I feel I ought to know this as I apparently wrote a long essay on
> using OLE with Excel to read and write data to and from Excel worksheets (
> http://www.jsoftware.com/jwiki/Scripts/OLEExcel).
>
> However, my recent attempts to run an arbitrary piece of VBA code fail with
> a "domain error" on "xlget'base activeworkbook'" in "xlwbws".
>
> Has anyone run arbitrary macros in spreadsheets?  Is there a more modern way
> to do this than OLE?
>
> Thanks,
>
> Devon
>

This works to run a macro called Main in a arbitrary Excel workbook  for me:

0. load xlutil.ijs
1. set JMACROS to the fully qualified name of my workbook containing a macro.
2. xlopen''
3. xlshow 1
4. xlcmd'base run ThisWorkbook.Main'

--
David Mitchell
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to