Before you can make any Origin C or X-Function call from a COM server, you need to check and wait for Origin C startup compile to finish, which will typically take a fraction of a second, but nevertheless the waiting is needed.
Currently, there is no exposed COM property or method for this checking, but there exists a LabTalk command to wait up to a specified length of time (timeout in seconds), as shown below:
sec -poc 3;//wait up to 3 sec for OC to be ready
The actual waiting time varies but the LabTalk command will return as soon as OC is ready. You can try to use a shorter timeout value like 2 but it would be safer to use a longer timeout.
The following small VBA example illustrates how this work:
Private Sub CommandButton_Click() Dim app As Origin.ApplicationSI Dim wbk As Origin.WorksheetPage Dim Wks As Origin.Worksheet Set app = New Origin.ApplicationSI app.NewProject 'wait for OC to be ready app.Execute ("sec -poc 3.5") 'call built-in XF to create a new folder called test and change to it app.Execute ("pe_mkdir test;pe_cd test") 'add new book in this new folder and set active sheet to 5 columns Set wbk = app.WorksheetPages.Add Set Wks = wbk.Layers(0) Wks.Cols = 5 'in case Origin was hidden, show it now app.Visible = MAINWND_SHOW End Sub