如何确定OLE域中存储的文件的文件类型/扩展名? [英] How can I determine filetype/extension of files stored in OLE fields?

查看:135
本文介绍了如何确定OLE域中存储的文件的文件类型/扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序允许在OLE字段中嵌入存储任何选定的文件

。该文件可能已被拖放到该字段中,或者可能已使用公共文件对话框以编程方式选择并导入

。无论如何,我需要确定已经存储在我的OLE

字段中的每个文件的

文件类型/扩展名,并将其显示给用户。


双击原始OLE字段或使用

.Verb = acOLEVerbOpen

.Action = acOLEActivate

方法将启动任何与OLE字段中存储的文件类型相关联的应用程序,因此,不知何故,该信息(.XLS,

..DOC,.MPG ,. PDF等等)必须可用 - 但在哪里?我希望能够以一种形式列出我的记录,其中包含沿着

的OLE字段以及描述OLE内容的其他信息,例如size(可获得的

通过FileSize函数)。有没有办法让我获得

扩展名?


感谢您提供任何帮助!

解决方案

它可以启动相应的应用程序,但不一定意味着它知道原始文件的名称。它可能只是存储一个所谓的ProgID,例如。 " Excel.Application" ;.这足以确定相关应用程序的
。如果对象是嵌入的 - 没有链接 -

我怀疑是否存储了原始文件的名称。


HTH,

TC

" Keith Brown" < KS ***** @ one.net>在留言中写道

news:3c ************************** @ posting.google.c om ...

我有一个应用程序允许在OLE字段中嵌入存储任何选定的文件。该文件可能已被拖放到该字段中,或者可能已使用公共文件对话框以编程方式选择和导入该文件。无论如何,我需要确定已存储在我的OLE
字段中的每个文件的
文件类型/扩展名,并为用户显示它。

双击原始OLE字段或使用
.Verb = acOLEVerbOpen
.Action = acOLEActivate
方法将启动任何与OLE字段中存储的文件类型相关联的应用程序,所以,不知何故,那些信息(.XLS,
。DOC,.MPG,.PDF等)必须可用 - 但在哪里?我希望能够在表单中列出包含OLE字段的记录以及描述OLE内容的其他信息,例如大小(可通过FileSize函数获取) 。有没有办法让我获得文件
扩展名?

感谢您提供的任何帮助!


" TC" < a@b.c.d>在消息新闻中写道:< 1067313170.971034@teuthos> ...

它可以启动相应的应用程序这一事实并不一定意味着它知道原始文件的名称。它可能只是存储一个所谓的ProgID,例如。 " Excel.Application" ;.这足以确定相关的应用程序。如果对象是嵌入的 - 没有链接 -
我怀疑是否存储了原始文件的名称。




对。我认为完整的文件名已经不再可用了,而且确实

不需要它。你引用的ProgID甚至可能比扩展名更好

,因为它说明了

相关应用程序的实际名称。如果有人能够展示一些可以产生任何一个代码的代码,我会非常高兴的!感谢您的回复。


如果您查看该字段中的实际内容,您会发现它包含

文件名和文件的完整(短)路径。


所以一个令人讨厌的第一个代码获取此信息可能看起来像这样


函数PathFromOLEField()

Dim loDb作为DAO.Database

Dim loRst作为DAO.Recordset

Dim loFld作为DAO.Field

Dim varChunk As Variant

Dim lngCount As Long

Dim strRet As String

Dim strFile As String

Dim strPath As String

Dim intInstr As Integer


设置loDb = Access.CurrentDb

设置loRst = loDb.OpenRecordset (表1)

设置loFld = loRst.Fields(嗯)

Do until loRst.EOF

varChunk = loFld .GetChunk(70,500)

strRet =""

对于lngCount = LBound(varChunk)到UBound(varChunk)

strRet = strRet& Chr(varChunk(lngCount))

下一页

intInstr = InStr(strRet,Chr(0))

strFile = Left(strRet,intInstr - 1)

strRet = Mid(strRet,intInstr + 1)

intInstr = InStr(strRet,Chr(0)& Chr(0))

strPath = Left(strRet,intInstr - 1)

Debug.Print strFile

Debug.Print strPath

loRst.MoveNext

循环

设置loFld = Nothing

loRst.Close

设置loRst = Nothing

设置loDb = Nothing

结束功能


Terry


" Keith Brown" < KS ***** @ one.net>在留言中写道

news:3c ************************** @ posting.google.c om ...

" TC" < a@b.c.d>在消息新闻中写道:< 1067313170.971034@teuthos> ...

它可以启动相应的应用程序这一事实并不一定意味着它知道原始文件的名称。它可能只是存储一个所谓的ProgID,例如,
。 " Excel.Application" ;.这足以确定相关申请的
。如果嵌入了对象 - 而不是
链接 - 我怀疑是否存储了原始文件的名称。



对。我认为完整的文件名不再可用,而且确实没有必要。您引用的ProgID甚至可能比扩展名更好,因为它会明确
相关应用程序的实际名称。如果有人可以向我展示一些可能产生任何一个代码的代码,我会很高兴的!感谢您的回复。



I have an application that allows embedded storage of ANY chosen file
in an OLE field. The file could have been dragged-and-dropped into
the field or it might have been selected and imported programmatically
using the common file dialog. Regardless, I need to determine the
filetype/extension of each of these files already stored in my OLE
fields and display it for the user.

Double-clicking the raw OLE field or using the
.Verb = acOLEVerbOpen
.Action = acOLEActivate
methods will launch whatever application is associated with the type
of file stored in the OLE field, so, somehow, that information (.XLS,
..DOC, .MPG, .PDF, etc.) must be available -- but where? I want to be
able to list, in a form, my records that contain the OLE fields along
with other info describing the OLE contents, such as size (obtainable
via the FileSize function). Is there a way for me to get at the file
extension as well?

Thanks for any help you can offer!

解决方案

The fact that it can launch the appropriate application, does not
necessarily mean that it knows the name of the original file. It might just
be storing a so-called ProgID, eg. "Excel.Application". That is enough to
identify the relevant application. If the object is embedded - not linked -
I doubt that the name of the original file is stored, at all.

HTH,
TC
"Keith Brown" <ks*****@one.net> wrote in message
news:3c**************************@posting.google.c om...

I have an application that allows embedded storage of ANY chosen file
in an OLE field. The file could have been dragged-and-dropped into
the field or it might have been selected and imported programmatically
using the common file dialog. Regardless, I need to determine the
filetype/extension of each of these files already stored in my OLE
fields and display it for the user.

Double-clicking the raw OLE field or using the
.Verb = acOLEVerbOpen
.Action = acOLEActivate
methods will launch whatever application is associated with the type
of file stored in the OLE field, so, somehow, that information (.XLS,
.DOC, .MPG, .PDF, etc.) must be available -- but where? I want to be
able to list, in a form, my records that contain the OLE fields along
with other info describing the OLE contents, such as size (obtainable
via the FileSize function). Is there a way for me to get at the file
extension as well?

Thanks for any help you can offer!



"TC" <a@b.c.d> wrote in message news:<1067313170.971034@teuthos>...

The fact that it can launch the appropriate application, does not
necessarily mean that it knows the name of the original file. It might just
be storing a so-called ProgID, eg. "Excel.Application". That is enough to
identify the relevant application. If the object is embedded - not linked -
I doubt that the name of the original file is stored, at all.



Right. I figured the full filename was no longer available and really
have no need for it. The ProgID you refer to might even be better
than an extension, since it spells out the actual name of the
associated application. I would be pretty happy if someone could show
me some code that could produce either one! Thanks for your response.


If you look at what''s actually in the field you''ll find that it contains the
filename and the full (short) path to the file.

So a nasty first stab at code to get this info could look like this

Function PathFromOLEField()
Dim loDb As DAO.Database
Dim loRst As DAO.Recordset
Dim loFld As DAO.Field
Dim varChunk As Variant
Dim lngCount As Long
Dim strRet As String
Dim strFile As String
Dim strPath As String
Dim intInstr As Integer

Set loDb = Access.CurrentDb
Set loRst = loDb.OpenRecordset("Table1")
Set loFld = loRst.Fields("Hmmm")
Do Until loRst.EOF
varChunk = loFld.GetChunk(70, 500)
strRet = ""
For lngCount = LBound(varChunk) To UBound(varChunk)
strRet = strRet & Chr(varChunk(lngCount))
Next
intInstr = InStr(strRet, Chr(0))
strFile = Left(strRet, intInstr - 1)
strRet = Mid(strRet, intInstr + 1)
intInstr = InStr(strRet, Chr(0) & Chr(0))
strPath = Left(strRet, intInstr - 1)
Debug.Print strFile
Debug.Print strPath
loRst.MoveNext
Loop
Set loFld = Nothing
loRst.Close
Set loRst = Nothing
Set loDb = Nothing
End Function

Terry

"Keith Brown" <ks*****@one.net> wrote in message
news:3c**************************@posting.google.c om...

"TC" <a@b.c.d> wrote in message news:<1067313170.971034@teuthos>...

The fact that it can launch the appropriate application, does not
necessarily mean that it knows the name of the original file. It might just be storing a so-called ProgID, eg. "Excel.Application". That is enough to identify the relevant application. If the object is embedded - not linked - I doubt that the name of the original file is stored, at all.



Right. I figured the full filename was no longer available and really
have no need for it. The ProgID you refer to might even be better
than an extension, since it spells out the actual name of the
associated application. I would be pretty happy if someone could show
me some code that could produce either one! Thanks for your response.



这篇关于如何确定OLE域中存储的文件的文件类型/扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆