1.4.1 Data Import to Origin Workbook

pCLAMP Import using X-Function

The following example shows how to call X-Function from COM.

Private Sub XF_Click()
    Dim app As Origin.Application
    Set app = New Origin.ApplicationSI
    'before we can run OC (XF is OC), we need to make sure OC startup compile/link is done
    app.Execute ("sec -poc 3") 'wait up to 3 sec, actually will be far shorter
    Dim wbk As Origin.WorksheetPage
    Set wbk = app.WorksheetPages.Add
    Dim strFileName As String
    'replace with your actual pCLAMP file name
    strFileName$ = "D:\Origin61\pClamp\96322002.ABF"
    'put filename into Origin project variable fname$ as all import XF assumes that
    'and this makes it easy to call the XF without passing it on the command line
    app.LTStr("fname$") = strFileName$
    'run pCLAMP import XF and turn off plotting XFbar
    wbk.Execute ("imppClamp options.XFBar:=0")
    Dim wks As Origin.Worksheet
    Dim Col As Origin.Column
    Set wks = wbk.Layers(0) 'only one sheet(layer) for pCLAMP import
    Set Col = wks.Columns(0) 'get the first column
    Cells(1, 1) = Col.LongName 'put the long name to Excel top-left cell
    Cells(2, 1) = Col.Units
    Cells(3, 1) = Col.EvenSampling 'Sampling interval
    app.Visible = MAINWND_SHOW
End Sub