PerlScript in Excel

darobin on 2003-01-22T11:53:36

Has anyone used the above combination? A friend of mine has an assignment to write a client in Excel (don't ask) that fetches some XML from a server and updates the cells dynamically. Writing the file from the outside is not an option, so I was wondering if using PerlScript (instead of VBA) from inside Excel would be a good idea, and if anyone could point me in the right direction to know how to get it to work.


Microsoft Script Control (Perlscript in Excel)

osfameron on 2003-01-22T13:00:11

If you haven't got the Microsoft Script Control, download it from somewhere in http://msdn.microsoft.com/scripting.

Then in Excel, set Tools - References - Microsoft Script Control.

In your code, you can now eval and execute Perl code, and use it in any Functions that you've declared as public - here's a trivial example:

Option Explicit
Private sc As New ScriptControl

Public Function uc(txt As String) As String
    sc.Language = "PerlScript"
    uc = sc.Eval("uc(" & txt & ")")
End Function
Now you can type =uc("hello") in your spreadsheet to call the above function.

You can even use modules; I had an example using Lingua::EN::Numbers, but I can't lay my hands on it at the moment.

Hope this helps.

Re:Microsoft Script Control (Perlscript in Excel)

darobin on 2003-01-22T14:26:26

Thanks a lot this really really helps. I'm left with what looks like a problem anyone with VBA experience must know about but I don't... When I try to call my function, what appears in the sheet is "#VALUE!". Obviously there is some sort of error on the value I'm feeding it, but I can't seem to get it to go away and Google ain't helping :/

Thanks a lot, as soon as I sort this out it ought to make someone's life a lot more viable.