Class CustomProperty (Excel VBA)

The class CustomProperty represents identifier information, which can be used as metadata for XML.

Set

To use a CustomProperty class variable it first needs to be instantiated, for example

Dim strName As String: strName = 
Dim ws As Worksheet: Set ws = 
Dim cprp As CustomProperty
Set cprp = ws.CustomProperties.Add(Name:=strName, Value:=)

The following procedures can be used to set variables of type CustomProperty: Worksheet.CustomProperties, CustomProperties.Item and CustomProperties.Add

For Each

Here is an example of processing the CustomProperty items in a collection.

Dim ws As Worksheet: Set ws = 
Dim cprpCustomPropertie As CustomProperty
For Each cprpCustomPropertie In ws.CustomProperties
	
Next cprpCustomPropertie

CustomProperties.Add

Adds custom property information.

Syntax : expression.Add (Name, Value)

Sub CheckCustomProperties() 
 
 Dim wksSheet1 As Worksheet 
 
 Set wksSheet1 = Application.ActiveSheet 
 
 ' Add metadata to worksheet. 
 wksSheet1.CustomProperties.Add _ 
 Name:="Market", Value:="Nasdaq" 
 
 ' Display metadata. 
 With wksSheet1.CustomProperties.Item(1) 
 MsgBox .Name & vbTab & .Value 
 End With 
 
End Sub

Arguments

The following arguments are required:

Name (String) - The name of the custom property.

Value (Variant) - The value of the custom property.

CustomProperties.Count

Returns a Long value that represents the number of objects in the collection.

CustomProperties.Item

Returns a single object from a collection.

Syntax : expression.Item (Index)

Index: The index number of the object.

Sub CheckCustomProperties() 
 
 Dim wksSheet1 As Worksheet 
 
 Set wksSheet1 = Application.ActiveSheet 
 
 ' Add metadata to worksheet. 
 wksSheet1.CustomProperties.Add _ 
 Name:="Market", Value:="Nasdaq" 
 
 ' Display metadata. 
 With wksSheet1.CustomProperties.Item(1) 
 MsgBox .Name & vbTab & .Value 
 End With 
 
End Sub

CustomProperties.Parent

Returns the parent object for the specified object. Read-only.

Delete

Deletes the object.

You can delete custom document properties, but you cannot delete a built-in document property.

Name

Returns or sets a String value representing the name of the object.

Parent

Returns the parent object for the specified object. Read-only.

Value

Synonym for the Borders.LineStyle property.