Sheet Custom Property – Sheet Custom Property Exists
Checks whether a custom property with the specified name exists in a given Excel.CustomProperties collection.
Since direct access by property name is not supported, the function iterates through the collection to find a match. Returns False if an exception occurs or if the property is not found.
VB
Public Function xlPropertyExists(customProperties As CustomProperties,
propertyName As String) As Boolean
Dim propToCheck As CustomProperty = Nothing
'Check if exists - must enumerate to find the property, direct access by name not working
Try
For Each cp As CustomProperty In customProperties
If cp.Name = propertyName Then
propToCheck = cp
Exit For
End If
Next
If propToCheck IsNot Nothing Then Return True
Catch ex As Exception
Return False
End Try
Return False
End Function