You are reading help file online using chmlib.com
|
Object: SpObjectToken
The GetAttribute method returns the value of the specified attribute.
The String returned contains the value for the Attribute. If the Attribute is present but does not contain additional information, the String will be Empty. If the Attribute is not present, SPERR_NOT_FOUND is returned. Not all engines support all attributes and it is possible to customize attributes for each engine.
SpObjectToken.GetAttribute(
AttributeName As String
) As String
The GetAttribute method returns a String variable.
In Visual Basic, attempting to access a nonexistent Attribute will cause a run-time error. Therefore, it is recommended to include an On Error statement trapping such cases.
The following code snippet retrieves the information associated with requested attribute. While the actual values will vary among engines. For the Microsoft speech engine, Microsoft Mary is returned for the nameAttribute. VendorAttribute will be Empty since the VendorPreferred attribute has no additional information associated with it. Even so, VendorPreferred has significance merely if it is present or not. However, an SPERR_NOT_FOUND will occur for FakeAttribute since it should not be present.
Dim objVoice As SpeechLib.SpVoice
Set objVoice = New SpeechLib.SpVoice
Dim objToken As SpeechLib.SpObjectToken
Set objToken = objVoice.Voice
On Error GoTo ErrorHandler
Dim nameAttribute, vendorAttribute, fakeAttribute As String
nameAttribute = objToken.GetAttribute("Name")
vendorAttribute = objToken.GetAttribute("VendorPreferred")
fakeAttribute = objToken.GetAttribute("FakeAttribute")
Exit Sub
ErrorHandler:
'Error handling code here
Debug.Print Err.Number
End Sub
You are reading help file online using chmlib.com
|