设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 4132|回复: 5
打印 上一主题 下一主题

excel表中图片引用

[复制链接]
1#
发表于 2011-6-15 02:47:35 | 显示全部楼层

excel表中图片引用 ›

本帖最后由 joyark 于 2011-6-15 03:20 编辑

回复 nantong718 的帖子

參考4樓例子
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 And Target.Column = 2 And Target.Row > 2 Then
For Each im In ActiveSheet.Pictures
If im.Top = Target(1, 2).Top Then im.Delete: Exit For
Next
pic = ThisWorkbook.Path & "\照片\" & Target & ".jpg"
If Dir(pic) = "" Then Exit Sub
Me.Pictures.Insert(pic).Select '当前文件所在目录下以单元内容为名称的.jpg图片
With Selection
ta = Target(1, 3).MergeArea.Height '(合并)单元高度
tb = Target(1, 3).MergeArea.Width '(合并)单元宽度
tc = .Height '图片高度
td = .Width '图片宽度
tm = Application.WorksheetFunction.Min(ta / tc, tb / td) '单元与图片之间长宽差异比例的最小值
.Height = tc * tm '按比例调整图片宽度
.Width = td * tm '按比例调整图片高度
.Top = Target(1, 3).Top + (ta - .Height) / 2 '垂直居中:
.Left = Target(1, 3).Left + (tb - .Width) / 2 '水平居中:
End With
Target.Select
End If
End Sub



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
2#
发表于 2011-6-16 22:53:09 | 显示全部楼层
回复 nantong718 的帖子

改動模2或模3
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-16 20:02 , Processed in 0.079389 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表