将图像嵌入表格中 [英] Embedding images into a table

查看:54
本文介绍了将图像嵌入表格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用代码将一些BMP文件嵌入到

现有表中的OLE字段(称为BMP)中。我创建了从图像文件夹中获取

文件名的代码,在

表中找到相应的记录并打开该记录进行编辑(RST.Edit) 。但是,我很难将图像放入OLE字段。
如果我从
> http://support.microsoft.com/default.aspx/kb/158941


然后在RST!BMP.Class =" Paint.Picture"我收到错误Method or

数据成员未找到;同上OLETypeAllowed,SorceDoc和

行动。如果我只是尝试RST!BMP = strFileName,然后是RST.Update,

那么该字段显示长二进制数据。但无论是什么内容都是

而不是图像。很明显,我需要以某种方式准备OLE字段,但是根据微软的例子,它通过一个表格

直接与表格相比似乎是不同的。


有人可以帮我解释语法吗?非常感谢

I want to embed some BMP files into an OLE field (called BMP) in an
existing table using code. I''ve created the code that grabs the
filename from the image folder, finds the corresponding record in the
table and opens that record for editing (RST.Edit). However, I''m
having difficulty putting the image into the OLE field. If I borrow
from the code that appears in http://support.microsoft.com/default.aspx/kb/158941,
then at RST!BMP.Class = "Paint.Picture" I get the error "Method or
data member not found"; ditto with OLETypeAllowed, SorceDoc and
Action. If I just try RST!BMP = strFileName, followed by RST.Update,
then the field displays "Long Binary Data" but whatever is in it is
not an image. Clearly, I need to prepare the OLE field somehow but it
seems to be different doing it directly to the table than via a form
as per Microsoft''s example.

Could someone please help me with the syntax? Many thanks

推荐答案

发布你正在使用的代码。


-


HTH

Stephen Lebans
http:/ /www.lebans.com

访问代码,提示和技巧

请只回复新闻组,以便每个人都能受益。

安东尼 < a ************* @ gmail.comwrote in message

news:dd ***************** ***************** @ v4g2000h sf.googlegroups.com ...
Post the code you are using.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"anthony" <an*************@gmail.comwrote in message
news:dd**********************************@v4g2000h sf.googlegroups.com...

>我想嵌入一些使用代码将BMP文件存入

现有表中的OLE字段(称为BMP)。我创建了从图像文件夹中获取

文件名的代码,在

表中找到相应的记录并打开该记录进行编辑(RST.Edit) 。但是,我很难将图像放入OLE字段。
如果我从

=_ blank> http://support.microsoft.com/default.aspx/kb/158941


然后在RST!BMP.Class =" Paint.Picture"我收到错误Method or

数据成员未找到;同上OLETypeAllowed,SorceDoc和

行动。如果我只是尝试RST!BMP = strFileName,然后是RST.Update,

那么该字段显示长二进制数据。但无论是什么内容都是

而不是图像。很明显,我需要以某种方式准备OLE字段,但是根据微软的例子,它通过一个表格

直接与表格相比似乎是不同的。


有人可以帮我解释语法吗?非常感谢
>I want to embed some BMP files into an OLE field (called BMP) in an
existing table using code. I''ve created the code that grabs the
filename from the image folder, finds the corresponding record in the
table and opens that record for editing (RST.Edit). However, I''m
having difficulty putting the image into the OLE field. If I borrow
from the code that appears in
http://support.microsoft.com/default.aspx/kb/158941,
then at RST!BMP.Class = "Paint.Picture" I get the error "Method or
data member not found"; ditto with OLETypeAllowed, SorceDoc and
Action. If I just try RST!BMP = strFileName, followed by RST.Update,
then the field displays "Long Binary Data" but whatever is in it is
not an image. Clearly, I need to prepare the OLE field somehow but it
seems to be different doing it directly to the table than via a form
as per Microsoft''s example.

Could someone please help me with the syntax? Many thanks



延迟道歉 - 这是代码


Dim strBMPDir As String

Dim strFileName As String

Dim DB As Database

Dim RST As Recordset

Dim strSQL As String


On Error GoTo errH

设置DB = CurrentDb()


strBMPDir =" i:\ photos \\ \\ bmp"

strFileName = Dir(strBMPDir&" \"&" * .bmp",vbNormal)

strFileName = Left(strFileName,14 )

做Len(strFileName)= 14

strSQL =" SELECT tblPhoto.PhotoID,tblPhoto.Image,tblPhoto.BMP"

strSQL = strSQL& " FROM tblPhoto"

strSQL = strSQL& " WHERE(((tblPhoto.Image)="&"''"& strFileName&

"''"&"));"

设置RST = DB.OpenRecordset(strSQL)

使用RST

..编辑

!BMP.Class =" Paint.Picture" ''这是失败的地方,方法或

未找到数据成员;接下来的三行同上

!BMP.OLETypeAllowed = acOLEEmbedded

!BMP.SourceDoc = strBMPDir& " \" &安培; strFileName& " .bmp"

!BMP.Action = acOLECreateEmbed

..update

strFileName = Dir

strFileName =左(strFileName,14)

循环


X:

退出子


errH:


MsgBox Err.Description

恢复X

Apologies for the delay - here is the code

Dim strBMPDir As String
Dim strFileName As String
Dim DB As Database
Dim RST As Recordset
Dim strSQL As String

On Error GoTo errH
Set DB = CurrentDb()

strBMPDir = "i:\photos\bmp"
strFileName = Dir(strBMPDir & "\" & "*.bmp", vbNormal)
strFileName = Left(strFileName, 14)
Do While Len(strFileName) = 14
strSQL = "SELECT tblPhoto.PhotoID, tblPhoto.Image, tblPhoto.BMP"
strSQL = strSQL & " FROM tblPhoto"
strSQL = strSQL & " WHERE (((tblPhoto.Image)=" & "''" & strFileName &
"''" & "));"
Set RST = DB.OpenRecordset(strSQL)
With RST
..Edit
!BMP.Class = "Paint.Picture" ''This is where it fails with "Method or
data member not found"; ditto for the next three lines
!BMP.OLETypeAllowed = acOLEEmbedded
!BMP.SourceDoc = strBMPDir & "\" & strFileName & ".bmp"
!BMP.Action = acOLECreateEmbed
..update
strFileName = Dir
strFileName = Left(strFileName, 14)
Loop

X:
Exit Sub

errH:

MsgBox Err.Description
Resume X


" ;安东尼" < a ************* @ gmail.comwrote in message

news:65 ***************** ***************** @ f3g2000h sg.googlegroups.com ...
"anthony" <an*************@gmail.comwrote in message
news:65**********************************@f3g2000h sg.googlegroups.com...

对延迟道歉 - 这里是代码


使用RST

。编辑

!BMP.Class =" Paint.Picture" ''这是失败的地方,方法或

未找到数据成员;接下来的三行同上

!BMP.OLETypeAllowed = acOLEEmbedded

!BMP.SourceDoc = strBMPDir& " \" &安培; strFileName& " .bmp"

!BMP.Action = acOLECreateEmbed
Apologies for the delay - here is the code

With RST
.Edit
!BMP.Class = "Paint.Picture" ''This is where it fails with "Method or
data member not found"; ditto for the next three lines
!BMP.OLETypeAllowed = acOLEEmbedded
!BMP.SourceDoc = strBMPDir & "\" & strFileName & ".bmp"
!BMP.Action = acOLECreateEmbed



我准备好在这里被火焰击落但是AIUI! Fieldname期望该字段的值为
,我认为没有任何参数。代码

编译吗?你在模块中声明了Option Explicit吗?


Keith。
www.keithwilby.com

I''m ready to be shot down in flames here but AIUI !Fieldname is expecting a
value for that field, I don''t think there are any arguments. Does the code
compile? Do you have Option Explicit declared in the module?

Keith.
www.keithwilby.com


这篇关于将图像嵌入表格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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