ACC: Finding the OLE ClassKey of an Embedded Object (1.x/2.0)ID: Q99319
|
Advanced: Requires expert coding, interoperability, and multiuser skills.
Microsoft Access places a wrapper of information around an OLE object
before it stores the object in a table. The Name and ClassKey of the
object start at byte count 21 and are stored from there as two
zero-terminating strings. By reading the field as a text field, you
can parse out the ClassKey.
This article describes how to use Access Basic to find the ClassKey of
an embedded object with an OLE-Object data type.
NOTE: This technique does not work if the OLE object is larger than 64K. In
this case you'll see the error:
Object has no value
When an OLE object is stored in a table, the ClassKey is the second
null-terminated string after the 20th byte in the object. It can be
read as text with the following Access Basic code:
NOTE: In the following sample code, an underscore (_) is used as a
line-continuation character. Remove the underscore from the end of the line
when re-creating this code in Access Basic.
Function GetObjectClass$ ()
If IsNull(screen.activeform!Photo) Then
GetObjectClass$ = "n/a"
Else
MyChunk$ = Mid(screen.activeform!Photo, 21, 40)
NullOne% = InStr(1, MyChunk$, Chr$(0))
NullTwo% = InStr(NullOne% + 1, MyChunk$, Chr$(0))
GetObjectClass$ = Mid(MyChunk$, NullOne% + 1, _
NullTwo% - NullOne% - 1)
End If
End Function
ControlName: ObjClassKey
ControlSource: =GetObjectClass()
For more information about calling the RegQueryValue() function to get
the Class Name of an OLE object, please see the following article here in
the Microsoft Knowledge Base.
Q99322 ACC: Calling RegQueryValue() to get an OLE Object Class
Name
Microsoft Windows "Programmer's Reference," version 3.1, Volume 2,
page 282
Additional query words: dll classname class key
Keywords : IntpOle
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 23, 1999