Software Developer's Kit - ChemDraw

Send comments on this topic
Close Method
See Also 

Description

Member of ChemDraw Control.Documents.

Closes all the documents in the collection

Syntax

Visual Basic
Public Sub Close() 

Remarks

Closes all the documents in the collection of documents.

Example

'Declares variables 
 Dim myDocuments As ChemDrawControl11Ctl.Documents
 Set myDocuments = ctlChemDraw.Selection.Objects.Documents

 Private Sub Form_Load() 
    'sets document
     Set myDocuments.Item(1) = ctlChemDraw.ActiveDocument
 End Sub
 Private Sub Form_QueryUnload(Cancel As Integer, Unload Mode As Integer)
     If  myDocuments.Item(1).FullName <> "" Then
         If  ctlChemDraw.ActiveDocument.Modified = True Then
             msg = MsgBox("Document has been modified." & Chr(13) & "Save changes?", _
                   vbQuestion + vbYesNo, "Modification") 
             If  msg = 1 Then
                 myDocuments.Item(1).Save
             End If
         End If
     Else 
         msg = MsgBox("Document has not been saved." & Chr(13) & "Save data?", _
               vbQuestion + vbYesNo, "New") 
         If  msg = 1 Then
             myDocuments.Item(1).SaveAs CurDir() & "\FileName1.cdx", cdx
         End If
     End If
     myDocuments.Item(1).Close  
     Set myDocuments.Item(1) = Nothing
     End 
 End Sub

See Also