我想根据 Microsoft Excel 中的相关单元格值显示图像。
例如,
A1 = "mypic.png" B1 cell should show mypic.png
A2 = "anotherpic.png" B2 cell should show anotherpic.png
Run Code Online (Sandbox Code Playgroud)
图片在同一个目录下。
有什么办法吗?
使用此代码,您可以在单元格中插入图像F20,其路径存储在单元格中A1。使用完整路径,例如D:\one.jpg. 更改Tabelle1您的工作表名称。
Sub Test()
Dim objPicture As Picture
With Tabelle1.Cells(20, 6) ' Picture starts in cell F20 -> change as you need
Set objPicture = .Parent.Pictures.Insert(Tabelle1.Cells(1, 1).Value)
objPicture.Top = .Top
objPicture.Left = .Left
objPicture.Height = 150
objPicture.Width = 150
End With
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8469 次 |
| 最近记录: |