Introduction

This section provides language reference information on the Automation Server capability of Origin. Detailed information on methods and properties are provided.

For general information on the Automation Server feature, and information on how to connect to an Origin server from client applications such as Excel, Visual Basic, and LabVIEW, please refer to the help topic Automation Server and COM Client Programming under the Programming Guide chapter. Sample application files can be found in the \Samples\AutomationServer subfolder in the main Origin installation area.

The names of the Origin COM objects placed in the registry are:

COM Object Name | Description
Origin.Application | This is a multi-instance. Each request to create an object will launch a new instance of Origin.
Origin.ApplicationSI | This is single instance. It will pick up a running instance of Origin if one is present.

Methods:

boolean Execute(BSTR script, [optional] VARIANT name);

boolean PutMatrix(BSTR name, VARIANT data);

VARIANT GetMatrix(BSTR name, [optional] VARIANT format);

boolean PutWorksheet(BSTR name, VARIANT data, [optional] VARIANT r1, [optional] VARIANT c1);

VARIANT GetWorksheet(BSTR name, [optional] VARIANT r1, [optional] VARIANT c1, [optional] VARIANT r2, [optional] VARIANT c2, [optional] VARIANT format);

boolean Load([optional] VARIANT path);

boolean Save([optional] VARIANT path);

boolean Reset([optional] VARIANT ReduceWks, [optional] VARIANT ReduceMatrices);

boolean Run();

boolean BeginSession();

boolean EndSession();

Properties:

BSTR LTStr(BSTR name);

double LTVar(BSTR name);

BSTR PageString(BSTR name, [optional] VARIANT LTString);


BeginSession

BeginSession (OriginPro Only)

The BeginSession method reserves the current Origin session for exclusive use. It has no meaning in the case of multi-instance Origin automation objects (Origin.Application,), in which case, any connection creates a separate Origin session.

boolean BeginSession();

VB Example:

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = BeginSession()

'other commands

bb = EndSession()

Parameters:

No parameters.

Return:

Returns True for success, False on failure.

SeeAlso:

EndSession


EndSession

EndSession (OriginPro Only)

The EndSession method releases the current Origin session from exclusive use. It has no meaning in the case of multi-instance Origin automation objects (Origin.Application,) in which case, any connection creates a separate Origin session.

boolean EndSession();

VB Example:

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = BeginSession()

'other commands

bb = EndSession()

Parameters:

No parameters.

Return:

Returns True for success, False on failure.

SeeAlso:

BeginSession


Execute

The Execute method executes a LabTalk script in specified context.

boolean Execute(BSTR script, [optional] VARIANT name);

VB Example:

'Assumes Graph1 exists and contains axis

'Setting x axis scale:

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = oApp.Execute("X1=0;X2=10","Graph1")

Parameters:

script | LabTalk script to execute.
name | Page name to serve as context for script execution; This is optional argument for window name which will execute LabTalk script in the context of the specified window.

Return:

Returns True for success, and False for failure.

SeeAlso:


GetMatrix

The GetMatrix method transfers data from specified Origin matrix.

VARIANT GetMatrix(BSTR name, [optional] VARIANT format);

VB Example:

'Assumes Matrix1 exists and contains data.

Dim oApp As Origin.ApplicationSI

Set oApp = GetObject("", "Origin.ApplicationSI")

array = oApp.GetMatrix("Matrix1")

Parameters:

name | Name of Origin matrix to receive data. Matrix dimensions will be adjusted to size of data.
format | This is optional argument reserved for future use. Defaults to 0.

Return:

Returns data as two dimensional safearray of doubles.

SeeAlso:

PutMatrix


GetWorksheet

The GetWorksheet method transfers data from specified Origin worksheet.

VARIANT GetWorksheet(BSTR name, [optional] VARIANT r1, [optional] VARIANT c1, [optional] VARIANT r2, [optional] VARIANT c2, [optional] VARIANT format);

VB Example:

'Assumes Data1 exists and contains data.

Dim oApp As Origin.ApplicationSI

Set oApp = GetObject("", "Origin.ApplicationSI")

array = oApp.GetWorksheet("Data1", 2, 3, 8, 4)

Parameters:

name | Name of Origin worksheet to receive data. Worksheet dimensions will be adjusted to size of data.
r1 | Starting (zero based) row index to get data from. This is optional argument, defaults to 0.
c1 | Starting (zero based) column index to get data from. This is optional argument, defaults to 0.
r1 | Ending (zero based) row index to get data from. This is optional argument, defaults to -1 (to the rest of worksheet).
c1 | Ending (zero based) column index to get data from. This is optional argument, defaults to -1 (to the rest of worksheet).
format | This is optional argument reserved for future use. Defaults to 0.

Return:

Returns data as two dimensional safearray.

SeeAlso:

PutWorksheet


Load

The Load method opens specified Origin project (.OPJ).

boolean Load([optional] VARIANT path);

VB Example:

'Assumes Project1.opj exist in c:\ folder

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = oApp.Load("c:\\project1")

Parameters:

path

Full path including file name of the Origin project to load. Extension (.opj) is not necessary. If only file name is given without full path, INI path is assumed. This is optional argument, if not specified, new project (UNTITLED) will be created.

Return:

Returns True for success, False on failure.

SeeAlso:

Save


PutMatrix

The PutMatrix method transfers two dimensional data to specified Origin matrix.

boolean PutMatrix(BSTR name, VARIANT data);

VB Example:

'Assumes Matrix1 exists.

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Dim mat(5, 1 To 2) As Long

Set oApp = GetObject("", "Origin.ApplicationSI")

'Create sample data

For i = 0 To 5

For j = 1 To 2

mat(i, j) = i + j

Next j

Next i

bb = oApp.PutMatrix("Matrix1", mat)

Parameters:

name | Name of Origin matrix to receive data. Matrix dimensions will be adjusted to size of data.
data | Two dimensional safearray that will be put into Origin matrix.

Return:

Returns True for success, False on failure.

SeeAlso:

GetMatrix


PutWorksheet

The PutWorksheet method transfers two dimensional data to specified Origin worksheet.

boolean PutWorksheet(BSTR name, VARIANT data, [optional] VARIANT r1, [optional] VARIANT c1);

VB Example:

'Assumes Data1 exists.

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Dim mat(5, 1 To 2) As Long

Set oApp = GetObject("", "Origin.ApplicationSI")

'Create sample data

For i = 0 To 5

For j = 1 To 2

mat(i, j) = i + j

Next j

Next i

bb = oApp.PutWorksheet("Data1", mat, 2, 3)

Parameters:

name | Name of Origin matrix to receive data. Matrix dimensions will be adjusted to size of data.
data | Two dimensional safearray that will be put into Origin worksheet.
r1 | Starting (zero based) row index to receive data. This is optional argument, defaults to 0.
c1 | Starting (zero based) column index to receive data. This is optional argument, defaults to 0.

Return:

Returns True for success, False on failure.

SeeAlso:

GetWorksheet


Reset

The Reset method clears all worksheets and matrices in current Origin session.

boolean Reset([optional] VARIANT ReduceWks, [optional] VARIANT ReduceMatrices);

VB Example:

'Assumes there are worksheets and matrices in current Origin session.

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = oApp.Reset(False)

Parameters:

ReduceWKs | If False, only worksheet cells will be emptied. If True, worksheets content will be emptied and size adjusted to two columns and 30 rows. This is optional argument, defaults to True.
ReduceMatrices | If False, only matrix cells will be set to missing value. If True, matrix cells will be set to missing and size adjusted to two columns and two rows. This is optional argument, defaults to True.

Return:

Returns True for success, False on failure.


Run

The Run method allows Origin session to finish current operations. It can be used after calling method that triggers lengthy auto-update calculations in Origin.

boolean Run();

VB Example:

'Assumes there are worksheets and matrices in current Origin session.

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = oApp.Run()

Parameters:

No parameters.

Return:

Returns True for success, False on failure.


Save

The Save method saves specified Origin project (.OPJ).

boolean Save([optional] VARIANT path);

VB Example:

Dim oApp As Origin.ApplicationSI

Dim bb As Boolean

Set oApp = GetObject("", "Origin.ApplicationSI")

bb = oApp.Save("c:\\project1")

Parameters:

path

Full path including file name of the Origin project to save. Extension (.opj) is not necessary. If only file name is given without full path, INI path is assumed. This is optional argument, if not specified, current project will be saved.

Return:

Returns True for success, False on failure.

SeeAlso:

Load


IsModified

IsModified property sets or clears modified flag for currently open Origin project without saving it.

boolean IsModified

VB Example:

Dim oApp As Origin.ApplicationSI

Set oApp = GetObject("", "Origin.ApplicationSI")

Dim bb As Boolean

bb = oApp.Load("c:\\project1")

bb = oApp.Reset() 'change current project

bb = oApp.IsModified 'True

oApp.IsModified = False 'clear modified flag

bb = oApp.Load("c:\\project1") 'restore to saved version - Save changes dialog absent

Parameters:

none

Type:

boolean

SeeAlso:

Load, Save


LTStr

The LTStr property provides access to LabTalk string variables.

BSTR LTStr(BSTR name);

VB Example:

Dim oApp As Origin.ApplicationSI

Dim str As String

Set oApp = GetObject("", "Origin.ApplicationSI")

str = "Test"

LTStr(ABC$) = str

str = LTStr(ABC$)

Parameters:

name

Name of the LabTalk variable to get/set property.

Type:

String

SeeAlso:

LTVar


LTVar

The LTVar property allows access to LabTalk floating point variables.

double LTVar(BSTR name);

VB Example:

Dim oApp As Origin.ApplicationSI

Dim var As double

Set oApp = GetObject("", "Origin.ApplicationSI")

var = 2.5

LTVar("XYZ") = var

var = LTVar("XYZ")

Parameters:

name

Name of the LabTalk variable to get/set property.

Type:

Double

SeeAlso:

LTStr


PageString

The PageString property allows access to Origin pages textual properties, or Origin Notes content.

BSTR PageString(BSTR name, [optional] VARIANT LTString);

VB Example:

'Assumes Data1 exist

Dim oApp As Origin.ApplicationSI

Set oApp = GetObject("", "Origin.ApplicationSI")

oApp.PageString("Data1", "Page.label$") = "text"

Parameters:

name | Name of the Origin page to access.
LTString | LabTalk string to specify context.

Type:

String

SeeAlso:

LTStr