我有代码将图像插入到WS中的某个单元格中,如下所示:
=============================================== ==============
Sub LoadPict()
Dim Pict As String
Dim cl As Range
Pict = "D:\Picture.JPG"
Set Rng = Range("D2")
For Each cl In Rng
Set myPicture = ActiveSheet.Pictures.Insert(Pict)
With myPicture
.ShapeRange.LockAspectRatio = msoFalse
.Height = 150
.Width = 144.75
.Top = Rows(cl.Row).Top
.Left = Columns(cl.Column).Left
.PrintObject = True
End With
Next
End If
End Sub
=============================================== ==============
问题是,要添加的代码是什么,以便我插入的图片自动包含边框线。
感谢您抽出时间帮助我。
答案 0 :(得分:2)
在Excel 2003或更高版本中,尝试使用Shapes.AddPicture方法添加图像,使用Shape.Line属性设置边框。
Sub LoadPict()
Dim Pict As String
Dim cl As Range
Dim myPicture As Shape
Pict = "D:\Picture.JPG"
Set Rng = Range("D2")
For Each cl In Rng
Set myPicture = ActiveSheet.Shapes.AddPicture(Pict, msoFalse, msoTrue, cl.Left, cl.Top, 144.75, 150)
With myPicture
.Line.Weight = 8
.Line.Visible = msoTrue
Next
End Sub