VB代码:在Excel表格中使用函数DISPIMG()显示图片
您可以使用以下VB代码来实现这个功能:
Sub DisplayImage()
Dim imgID As String
imgID = "ID_ID_8C0A3E9E0F244F8181E4157C71D4C1D6"
Dim imgPath As String
imgPath = "C:\path\to\your\image.jpg" '替换为您的图片路径
Sheets("Sheet1").Pictures.Insert(imgPath).Name = imgID
Sheets("Sheet1").Range("A1").Select
ActiveSheet.Shapes(imgID).Top = Selection.Top
ActiveSheet.Shapes(imgID).Left = Selection.Left
ActiveSheet.Shapes(imgID).LockAspectRatio = msoFalse
ActiveSheet.Shapes(imgID).Width = Selection.Width
ActiveSheet.Shapes(imgID).Height = Selection.Height
ActiveSheet.Shapes(imgID).Placement = xlMoveAndSize
End Sub
请确保将imgID设置为您想要显示的图像的ID,将imgPath设置为您图像的实际路径,并将"Sheet1"替换为您要在其中显示图像的工作表名称。
原文地址: https://www.cveoy.top/t/topic/pBGR 著作权归作者所有。请勿转载和采集!