发布网友 发布时间:2022-04-25 06:30
共2个回答
热心网友 时间:2023-11-03 09:34
这个需要和excel工作表事件进行配合才可完成,以下面模拟为例
在职工信息中表中为员工插入图片,当单击职工姓名时,就会出现职工的照片,需要做的前期准备就是,必须要将职工信息表和职工照片放在同一文件夹下。
在信息表中插入以下代码:
Private
Sub
Worksheet_SelectionChange(ByVal
Target
As
Range)
On
Error
Resume
Next
If
Target.Column
=
2
Then
Me.Image1.Visible
=
True
Image1.Picture
=
LoadPicture(ThisWorkbook.Path
&
"\员工照片\"
&
Target.Offset(0,
-1)
&
".jpg")
Image1.Left
=
Target.Left
+
Target.Width
Image1.Top
=
Target.Top
Else
Me.Image1.Visible
=
False
End
If
c
=
Target.Value
End
Sub
热心网友 时间:2023-11-03 09:34
Sub InsPic()
ActiveSheet.Pictures.Insert ( _
"W:\2015\1.jpg")
With Range("B23:AK39")
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Left = .Left
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Top = .Top
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Width = .Width
ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Height = .Height
End With
End Sub