'Declare the necessary STATISTICA Development Environment functions.
Declare Function StaOpenFile Lib "stadev32.dll" (ByVal szFileName As String) As Long
Declare Function StaGetData Lib "stadev32.dll" (ByVal hSF As Long, ByVal Var As Integer, ByVal CaseNo As Long, ByRef Value As Double) As Integer
Declare Function StaGetNVars Lib "stadev32.dll" (ByVal hSF As Long) As Integer
Declare Function StaGetNCases Lib "stadev32.dll" (ByVal hSF As Long) As Long
Declare Function StaCloseFile Lib "stadev32.dll" (ByVal hSF As Long) As Integer
Declare Function StaGetVarName Lib "stadev32.dll" (ByVal hSF As Long, ByVal Var As Integer, ByRef szName As String) As Integer
Declare Function StaGetCaseName Lib "stadev32.dll" (ByVal hSF As Long, ByVal CaseNo As Long, ByVal szName As String, ByVal BL As Integer) As Integer
Dim d As Double
Sub Macro1()
'Prompt the user for the .sta file to open.
myfile = InputBox(Prompt:="Enter the name of the file you would like to open", Title:="Enter filename", Default:="c:\stat\examples\adstudy.sta")
'Open the user-specified .sta file.
mydata = StaOpenFile(myfile)
'Determine the number of variables and cases of the user-specified data file.
numvar = StaGetNVars(mydata)
numcas = StaGetNCases(mydata)
'Put the data file name in the 4th row and 1st column on Sheet1.
Worksheets("Sheet1").Cells(4, 1) = myfile
'Begin loop to assign individual cells.
Cells(5, 1).Activate
For i = 1 To numvar
For j = 1 To numcas
Cell = StaGetData(mydata, i, j, d)
ActiveCell.Offset(j, i - 1).Value = d
Next j
Next i
'Close the .sta file.
StaCloseFile (mydata)
'End program.
End Sub
| Back to List of Programs |
![[StatSoft]](../../images/sssmall.gif)
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217
e-mail: info@statsoft.com
©Copyright StatSoft, Inc., 1984-2005.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.