Software Developer's Kit - ChemDraw

Send comments on this topic
Save Method
See Also 

Description

Member of ChemDrawCtl.

Saves changes to the file specified in the FullName property.

Syntax

Visual Basic
Public Sub Save() 

Example

Dim myDocument As Document

Private Sub cmdSave_Click() 
   'sets and saves document
    Set myDocument = ctlChemDraw.ActiveDocument
    myDocument.SaveAs CurDir() & "\FileName1.cdx", cdx
    Text1.text = myDocuments.FullName
End Sub
Private Sub cmdOpen_Click() 
   'opens and sets document
    ctlChemDraw.Open CurDir() & "\FileName2.cdx", False
    Set myDocuments = ctlChemDraw.ActiveDocument
End Sub
Private Sub ctlChemDraw_Validate(Cancel As Boolean) 
   'opens and sets document
    Text3.text = ctlChemDraw.ActiveDocument.NumPagesWide
End Sub
Private Sub Form_Load() 
   'opens and sets document
    Set myDocument = ctlChemDraw.ActiveDocumente
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, Unload Mode As Integer)
   If   myDocument.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
                myDocument.Save
            End If
        End If
    Else 
        msg = MsgBox("Document has not been saved." & Chr(13) & "Save data?", _
              vbQuestion + vbYesNo, "New") 
        If  msg = 1 Then
            myDocument.SaveAs CurDir() & "\FileName1.cdx", cdx
        End If
    End If
    myDocument.Close  
    Set myDocument = Nothing
    End 
End Sub

See Also