Databases Reference
In-Depth Information
In building such an example, it would be desirable for the application to have certain built-in
functionalities such as
1.
The ability to launch a new instance of Origin or utilize a preexisting instance of Origin
to perform the calculations.
2.
The ability to select the Equation type to be fit (mono or bis) by means of an option button.
3.
A means of selecting the data set to be fit. In this case, a drop-down box is utilized.
4.
A button to trigger the fitting of the data set in Origin.
5.
A plot template that provides a consistent look for all the analyzed data.
6.
Columns that contain both the raw data set and the fitted data set.
7.
A means of allowing the various fitting parameters to be fixed or to vary.
The difference in terms of functionality between the COM and DDE sample applications shown
is that the COM application takes the analysis portion a step further. Not only are results calculated
and returned, but the user can pick what parameters are allowed to vary during the fitting process.
In addition, a graph is returned to Excel that contains the raw data and the fitted curve. Figure
9.28 shows the completed sample application.
Prior to utilizing COM commands, a COM object must be declared that refers to the Origin
application. The easiest way to do this is to declare the COM application object at either the Module
level or within the “ThisWorkbook” object. This sample uses the latter and places the following
declaration in the “ThisWorkbook” object.
'Declare Origin Application as public object
Public ObjOrigin As Origin.Application
With the Origin application object declared, the application object variable can now be utilized
to send specific commands to Origin via Excel. The “Connect to Origin” button's code utilizes the
application object variable to start or reference the proper instance of Origin.
Private Sub Button_Start_Click()
'Check if user wants to launch new instance or try connecting
to an existing instance
If (OptionButton_New.Value) Then
On Error GoTo ErrMsg1
'Launch a new instance of Origin and connect to it
Set ThisWorkbook.ObjOrigin = GetObject("",
"Origin.Application")
Else
On Error GoTo ErrMsg1
'Connect to an existing Instance of Origin
Set ThisWorkbook.ObjOrigin = GetObject("",
"Origin.ApplicationSI")
End If
'Successfully connected to Origin
'Show/hide appropriate controls
CheckBox1.Visible = True
'Button_Start.Visible = False
Button_End.Visible = True
Search WWH ::




Custom Search