AddCustomItem Method

The AddCustomItem method allows you to add a custom metadata item to the custom items collection. Any existing item with the same will be replaced. Names are case-sensitive.

Syntax

NULL = objMC.AddCustomItem(ICustomMetadataItem * pItem)

Element

Description

NULL

The AddCustomItem method returns no value.

objMC

A Mathcad worksheet or region object.

pItem

The custom metadata item to be added, passed as a pointer.

Example

The following example sets a custom metadata item based on input from a Visual Basic form. A combobox is used to select the metadata type, while the name and value are input into text fields.

' Define a metadata object
Dim myMetaData As Object
Set myMetadata = CreateObject("Mathcad.CustomMetadataItem")

' See which the four types it is
If cmbType.Text = "Text"
   myMetaData.Type = mcCMTTexto
ElseIf cmbType.Text = "Date"
   myMetaData.Type = mcCMTDate
ElseIf cmbType.Text = "Number"
   myMetaData.Type = mcCMTNumber
ElseIf
   myMetaData.Type = mcCMTYesNo
End If

' Pull the Name and Value from text boxes
   myMetadata.Name = txtName.Text
   myMetaData.Value = txtValue.Text
   End If

' Set the metadata item for the worksheet.
Glob.objApp.ActiveWorksheet.Metadata.AddCustomItem myMetaData