Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you determine file type for OLE field?

Status
Not open for further replies.

TriscuiT

MIS
Jun 10, 2003
9
0
0
US
If your reply will be "you shouldn't store documents within an Access database" please do not waste the space. I don't have a choice in the matter.

Lets say that you have a table tblTest with 2 fields - an AutoNumber and an OLE Container. Now suppose that there are two records in this table. The first has a Word document stored in the OLE Container. The second has an Acrobat document stored in the OLE Container.

Access knows (at least for the MS products) what type of file is stored in the OLE field. You can see this if you open the table in Access. A Word document is listed as "Microsoft Word Document". The Acrobat document is list as "Long binary data".

My question: How do I access the properties to see whether it is "Microsoft Word Document" or "Long binary data"?

Thanks.
 
Look in the column properties. Here is an example to get you started.

Function catalogTCCat()
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO

Dim cg As New ADOX.Catalog
Dim tb As New ADOX.Table
Dim cn As ADODB.Connection
Dim cl As Column
Dim pp As Property

Set cg.ActiveConnection = CurrentProject.Connection

For Each tb In cg.Tables

If tb.Type = "TABLE" Then
'If tb.Type = "LINK" Then
Debug.Print "table name = "; "-------"; tb.Name; "--------"; tb.Type

For Each cl In tb.Columns
Debug.Print "property name = "; cl.Name
' Debug.Print "property value = "; pp.Value
Next
End If
Next
End Function
 
While that reveals a lot of information I was unable to find anything that would tell me the Type of the data file stored in an OLE field. Did I miss something?
 
Sorry, after thinking more about it, the column property would just indicate information about the data type not what is stored inside the OLE field. Perhaps you could cast the OLE field to a text type field and look if the first characters reveal what is contained.
 
I tried that. If there is a pattern there I was unable to detect it. Sadly, I could even find filenames with ".doc" extensions withing .pdf files. I am guessing that the .pdf was a .doc first. M$ has a way to tell what the data is, but they sure have obfuscated how they do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top