Creating a COFE document by automation
Creating a new COFE flowsheet document in an active document container
To create a new COFE document inside a container document, click on the Insert menu and choose Object (the precise menu structure may depend on the application). On the Create New tab, select "COCO/COFE Flowsheet document".
To edit the created document, double click on the COFE icon.
Using an existing fsd document on disk
To create a COFE document inside a container document that is based on an existing fsd document on disk, click on the Insert menu and choose Object (the precise menu structure may depend on the application). On the Create From File tab, click Browse. Select an existing fsd document.
Accessing the document's interfaces programmatically
To access the document's interfaces programmatically, study the documentation of the document container to make yourself familiar with the container's programming language and object model.
For example, in Microsoft Office applications, the programming language is Visual Basic for Applications (VBA), and you can access the embedded documents by examining the OLEObjects collection, and find the OLEObject object that has its OLEObject.progID member set to "COCO_COFE.Document". You can then assign its OLEObject.object member to a variable of type COFE_document. Or:
Dim obj As OLEObject Dim document As COFE_document For Each obj In myWorkSheet.OLEObjects If (obj.progID = "COCO_COFE.Document") Then Set document = obj.object Exit For End If Next
For the programming language of the container application to know about COFE's data types, you will have to set a reference to the type library of COFE. In VBA, this is done by choosing References from the Tools menu, and adding a reference to 'COFE'. If 'COFE' does not appear in the list, browse to the COCO installation folder, and select COFE.tlb (the type library containing COFE's type definitions).
You will also need access to the CAPE-OPEN type definitions. To do this, set a reference to the CAPE-OPEN 1.0 Type library, or the CAPE-OPEN 1.1 Type library, depending on your needs. These type libraries need to be installed; the COCO installer contains the installer for the type libraries, available from the CO-LaN web site. If - after installing the CAPE-OPEN type libraries - they do not show up in the list of available choices, browse to the installation directory, usually C:\Program Files\Common Files\CAPE-OPEN.
Creating a COFE document programmatically
To create a COFE document programmatically, first make sure to add COFE as a reference (see above). Then, create a new object of the COFE document type. For example, in VBA:
Dim document As COFE_Document Set document = New COFE_document
Alternatively, use CreateObject,
Dim document Set document = CreateObject("COCO_COFE.Document")
or, using an existing file:
Dim document As COFE_Document Set document = GetObject("mydocument.fsd")
(The advanced VBA user will have noticed that the second example did not declare the type of variable document and thus uses late binding, and therefore does not require a reference to the COFE type library. Using early binding however is the advised method).