Create a new component

Public Function NewComponent(compName As String, _
        ParentFolder As ComponentFolder) _
    As Component

    Dim myComp As Component
    Dim compFactory As ComponentFactory
    
    On Error GoTo NewComponentErr
    
    ' Get a ComponentFactory
    Set compFactory = ParentFolder.ComponentFactory
    
    ' Add the component
    Set myComp = compFactory.AddItem(Null)
    Dim errString As String
    
    If (compFactory.IsComponentNameValid(compName, errString)) Then
        myComp.name = compName
    Else
        myComp.name = "DefaultValidName"
        MsgBox errString
    End If
    
    myComp.Post
    
    Debug.Print CStr(myComp.Field("CO_FOLDER_ID"))
    'Return the new component.
    Set NewComponent = myComp
    
Exit Function
NewComponentErr:
    MsgBox err.Description
    
End Function