autstat Support

icon
Avatar
jla2w
Posts: 4
Dim rintf As New SExcelProto.RInterface
Dim vals(10) As Integer
rintf.GetArray "x", vals

I also tried other variations but vba doesn't seem to recognize anything related to SExcel, pls advise, tx
2017-12-06 21:15
Avatar
Thomas Baier
Moderator
Posts: 217
Did you add a reference to "SExcel" in the VBA editor?

Please use SExcel instead of SExcelProto since version 1.0

Thomas
2017-12-07 07:24
Avatar
jla2w
Posts: 4
Ok tx, got past that first hurdle. Now I have

Private Sub Worksheet_Change(ByVal Target As Range)

Dim rintf As New SExcel.RInterface
Dim vals(10) As Integer
rintf.GetArray "x", Me.Range("A3:A12")

End Sub

I have a vector x in R of length 10, but this gives me an error also (I tried a data frame version as well)

Run-time error '-2146233088 (80131500)'
Exception of type 'statconn.NET.Errors.SCException' was thrown
2017-12-07 14:08
Avatar
Thomas Baier
Moderator
Posts: 217
The questions we normally need:

Foreground or background server?
Are you already connected?
Do you have Autoconnect enabled?

Error-handling is a bit clumsy at the moment, the error code won't help. It would be a good idea to provide a step-by-step scenario to reproduce the problem (starting with start of all required applications).
2017-12-07 14:11
Avatar
jla2w
Posts: 4
Edit
Nevermind got it working, had to assign the variable to a new RInterface

Foreground server
I am connected in that I have R running and the ribbon commands work for me (I'm able to put and get variables from/into the sheet and see them in my running R window)

I do have SExcel as a reference and now I am able to define the variable seemingly properly (after alos using SExcel without proto). Very simple worksheet here is my code that crashes

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Me.Range("A1:K100")) Is Nothing Then
Dim rintf As SExcel.RInterface
rintf.PutArray "xTest", Me.Range("A1:B1")
'item_list = Application.Run("R.refresh")
End If

End Sub

All I want to do is see programatically that I can update my R state. I'd also like to call R functions that I define from vba passing in ranges as arguments, possible?

One example excel sheet with the trial, with lots of vba code demonstrating functionality, would be very useful given lack of documentation
2017-12-08 20:57
Avatar
Thomas Baier
Moderator
Posts: 217
Good to see that you got it working.

Yes, documentation and example code is "a bit" of a problem currently. Will provide a few new examples with the next release to show how coding in VBA works.
2017-12-09 09:49
icon