Thanks, David!
I've got the references dialogue box now thanks to your advice below, and
I've added j.dll to its list, which it shows as 'Jsoftware: JDLLServer Type
Library', and it's ticked. Great!
But, running your macro gives
Run-time error '429':
ActiveX component can't create object
And the debugger highlights the line
Status = jObject.DoR(("!" & Selection.Offset(0, 0).Value), rObject)
Getting close!
I can now write VBA functions in Excel. Nothing like mucking about in other
languages to raise one's appreciation of J.
Thanks for your patience!
Graham Parkhouse
On Mon 21 Feb David Mitchell wrote:
>
> Graham,
>
> You may have to coax Excel to show the Macro options.
>
> In Excel 2007, I clicked on the circular bubble in the upper left
> corner of the
> main Excel window. I clicked on the button labeled 'Excel Options' in
> the lower
> right of the sub-window. I then clicked on 'Show Developer Tab in the
> Ribbon'.
>
> In Excel 2010, I right-clicked on an empty area of the 'ribbon' and
> selected
> 'Customize the Ribbon'. I then checked off 'Developer' under 'Main
> Tabs' or
> 'All Tabs'.
>
> Once you have the Developer tab, you can open up the Visual Basic
> window. Once
> there, the menu option Tools->References will show you the available
> references.
> If J7 has been registered, you should see an option like 'J DLL
> Server
> (Version 3) Type Library' that you can check off.
>
> The J code is a bit subtle. This is the line that calls J to execute a
> text
> expression:
>
> Status = jObject.DoR(("!"& Selection.Offset(0, 0).Value), rObject)
>
> The J verb used is !, concatenated to the Value from the selected Cell,
> returning a value to rObject.
>
> This should work with user defined J verbs as well, once they are
> defined.
> --
> Good luck,
> David Mitchell
>
> On 2/21/2011 7:51, Graham Parkhouse wrote:
> > How do I do step 3, add the Excel Macro Reference to
> >
> > Jsoftware: JDLLServer Type Library?
> >
> > And where is the J in your example? I can't see how entering 123 0
> should be
> > expected to result in 123 1.21E+205.
> >
> > Gratefully
> >
> > Graham Parkhouse
> >
> > ----------------------------------------------
> >
> > On Sat 19 Feb, David Mitchell wrote:
> >
> > Here is an example:
> >
> > 1. I went to the bin install directory for J701 and ran this:
> >
> > regsvr32 j.dll
> >
> > 2. I created this Excel macro:
> >
> > Sub Main()
> > Dim jObject As New JDLLServerLib.JDLLServer
> > Dim rObject As Variant
> >
> > Sheets("Sheet1").Select
> > Range("A1").Select
> > Status = jObject.DoR(("!"& Selection.Offset(0, 0).Value),
> rObject)
> > Range("B1").Select
> > Selection.Value = Str(rObject)
> > jObject.Quit
> > End Sub
> >
> > 3. I added the Excel Macro Reference to
> >
> > Jsoftware: JDLLServer Type Library
> >
> > 4. I entered this into cells A1 and B1 in the Workbook Sheet1
> >
> > 123 0
> >
> > 5. I ran the macro and got this in cells A1 and B1:
> >
> > 123 1.21E+205
> >
> > ---------------------------------------------------------------------
> -
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
>
>
> ------------------------------
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> End of Programming Digest, Vol 65, Issue 46
> *******************************************
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm