Guidelines to convert Statistica Visual Basic Macro into Visual Studio Application

Guidelines to convert Statistica Visual Basic Macro into Visual Studio Application

book

Article ID: KB0076485

calendar_today

Updated On:

Products Versions
Spotfire Statistica 13 and higher

Description

This article has guidelines for the modifications to be made to the Statistica macro before it can be run as a custom Visual Studio application. Note that this article only serves as generic walk through of an example. Any assistance needed for a specific customization can be considered as a custom project that can be worked on by the TIBCO PSG (Professional Services Group) team with appropriate engagement.

PREREQUISITES
1. Statistica installation
2. Visual Studio

 

Resolution

For the purpose of this article, we'll assume the attached SVB macro that opens an example dataset in Statistica and plots a simple histogram is the macro we want to make into a Visual Studio Application.Note that depending on the version of Visual Studio used, the menu options and screenshots below may differ slightly.

1. Launch Visual Studio and select "Create a new project" . For older versions of Visual Studio, this may be File >>New Project

User-added image

2.   Select Console App (.NET Framework )

User-added image

3. Name your project appropriately. For this example, we are naming the project as StatHistogram. Click Create

User-added image
4. Before adding code from the SVB (Statistica Visual Basic) macro attached to the article, add appropriate Statistica library references. Select Project >> Add References >COM Type Libraries. For this example , we select STATISTICA Graphics Type Library and Statsoft STATISTICA dictionary library and click OK.

User-added image

5. Type the 2 lines below at the start of the code to import the libraries referenced above:

Imports STATISTICA
Imports STATISTICAGraphics

and add the first 2 lines within the Main module as :

        Dim sApp As New Application
        sApp.SWSInfo("admin", "[Admin password for Statistica enterprise]")

User-added image

NOTE : Above SWSInfo needs to be replaced with login information that corresponds to user's Statistica installation.

6. Open the attached Statistica Visual Basic macro and copy the code from the attached macro to the main module :

Revise the line 2
Set ssData = Spreadsheets.Open(Path &"\Examples\DataSets\Characteristics.sta",False) to  ssData = sApp.Spreadsheets.Open("C:\Program Files\Statistica\Statisrtica 13\Examples\DataSets\Characteristics.sta", False)

i.e Remove the "Set" and bind the Spreadsheets to the sApp object we created earlier. Note that if the line is Set ssData=ActiveDataSet from a recorded macro,we want to explicitly change it to use Spreadsheets.Open method to refer to the file instead.

Remove all consequent "Set" that is highlighted with a red rigged line :

User-added image

7. Rewrite all lines highlighted with a red rigged line by adding the appropriate module such as sApp.Analysis. The easiest way maybe to delete the preceding character and add it again for the Intellisense prompt and choose appropriately. In the below example we delete ( and add it again.

User-added image

Continue doing the same for all the red rigged lines.


User-added image


8. Once all the rigged lines are corrected, assign the output to a variable and save it some location as shown below . Comment out the line with newAnalysis.Routeoutput since this context works only within Statistica.

User-added image

Verify that the compiler displays "No issues found"

9. Save the code and then select Build>>Build Solution

User-added image

10. After the build succeeds click on the green triangle Start to debug and run the code

User-added image

11. From the [location that the project was saved in]\bin\Debug, double click on the [Solutionname].exe to run the program and verify that the output graph is generated in the location given in the code. 

User-added image

 

Issue/Introduction

Guidelines to convert Statistica Visual Basic Macro into Visual Studio Application

Attachments

Guidelines to convert Statistica Visual Basic Macro into Visual Studio Application get_app