ACC: How to Retrieve the Path for Linked OLE Objects (7.0/97)Last reviewed: June 24, 1997Article ID: Q170531 |
The information in this article applies to:
SUMMARYAdvanced: Requires expert coding, interoperability, and multiuser skills. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Microsoft Access provides no way to determine the path for a linked OLE object stored in a table. Therefore, the recommended approach is to create an additional text field in the table and store the path to the linked OLE object in that field. This article demonstrates how to use a Visual Basic for Applications procedure to retrieve the path for a linked OLE object from the object's OLE header. However, it is possible that this procedure may not work in some circumstances. Storing the path in a separate text field when you link the OLE object is the best way to ensure that you will be able to retrieve the path later. This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.
MORE INFORMATIONMicrosoft Access stores the path of a linked OLE object as part of the object's definition in the OLE object field. Because the definition of OLE object storage is not documented, the following procedure searches the object's OLE header for characters consistent with a file path. Specifically, the procedure searches for the first occurrence of the string ":\", which indicates a mapped drive path. From this, it derives the drive letter by obtaining the character which immediately precedes the ":\" occurrence. Then, it derives the remainder of the path by searching for the first null character following the ":\" occurrence. If the procedure cannot find an occurrence of the string ":\", it searches for the first occurrence of the string "\\", which indicates a UNC path. From this, it derives the remainder of the path by searching for the first null character following the "\\" occurrence. If the procedure does not find an occurrence of "\:" or "\\", it assumes the object is not linked and returns a Null value. NOTE: It is possible for the OLE header to contain an occurrence of either string pattern in a location that does not store the path to the linked object. If this occurs, the procedure returns a result that consists of garbage characters rather than the path to the linked object. To programmatically determine the path for a linked OLE object, follow these steps:
REFERENCESFor more information about the StrConv () function, search the Help Index for "StrConv." |
Keywords : IntpOle kbcode kbole PgmHowTo PgmParse
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |