Jump to content

macro code from StatSoft example appears to give an error


Recommended Posts

Hi Forum,

I was attempting to run a macro code example given on the StatSoft developer's network. Here is the URL:

http://sdn.statsoft.com/STATISTICAVisualBasic.aspxpage=method&class=Spreadsheet&item=VariableTextLabels&kind=sub

I loaded the recommended data set (Heart.sta) into a workbook along with the macro. When I run the macro, I get this message below. (the double quotes around the macro name are my own)

VBA Error in macro "Macro read variable text info" at line: 15

(10094) ActiveX Automation: Object var is 'Nothing'.

The line of code that appears to be in question is:

spr.VariableTextLabels(1,values(),labels(),descriptions())

I am supposing that the code is somehow not understanding which variable to use

The data set was set as the Active Input prior to my running the macro code.

I copied this code verbatim from the example at the URL (at least I thought I did) and ran it with the data set recommended in the example at the URL. What have I done wrong

I am using Statistica 64 11

AGA206F367304A11-V

Thanks to anyone who can set me straight on this.

 

Cliff

 

 

Here is the entirety of the code (copied from the URL above).

 

Option Base 1

Option Explicit

 

Sub Main()

'this example was written using the example data file heart.sta

Dim spr As Spreadsheet

'assigns the active spreadsheet to the object spr

Set spr = ActiveSpreadsheet

Dim values() As Double

Dim labels() As String

Dim descriptions() As String

'place the text label values, labels, and descriptions into their

'respective arrays.

spr.VariableTextLabels(1,values(),labels(),descriptions())

'display the first text label parameters as returned above.

MsgBox "Value = " + Str(values(1)) + vbCrLf + "Label = " + labels(1) + vbCrLf _

+ "Description = " + descriptions(1), vbOkOnly, "Variable Text Label"

End Sub

Link to comment
Share on other sites

  • 6 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...