作者:乔山办公网日期:
返回目录:excel表格制作
Sub addpic()
Range("b3").Select
ActiveSheet.Pictures.Insert ("D:\我的文档\图片收藏\2011-11-01_092832.jpg")
End Sub
Sub insertPic()
Dim i As Integer
Dim FilPath As String
Dim rng As Range
Dim s As String
With Sheet1
For i = 3 To .Range("a65536").End(xlUp).Row
FilPath = ThisWorkbook.Path & "\" & .Cells(i, 1).Text & ".jpg"
If Dir(FilPath) <> "" Then
.Pictures.Insert(FilPath).Select
Set rng = .Cells(i, 3)
With Selection
.Top = rng.Top + 1
.Left = rng.Left + 1
.Width = rng.Width - 1
.Height = rng.Height - 1
End With
Else
s = s & Chr(10) & .Cells(i, 1).Text
End If
Next
.Cells(3, 1).Select
End With
If s <> "" Then
MsgBox s & Chr(10) & "没有照片!7a686964616fe4b893e5b19e361"
End If
End Sub
太简单了
当你在picture的Picture属性中插入图片百后
在Picture属性格度中仍然会显示(Bitmap)(如果是bmp文件的话)
但是图知片已经插入了。
这是侯道要删除这个图片
将光标插入到(Bitmap)的前专面按Delete键就可以了。
然后就出现属(None)了就搞定了。
如果你知道图片来的Name
可以源,如名称百是"Picture 1"
xlSheet.Shapes("Picture 1").delete
如果不知道名称,知道在单元格的位度置,譬如顶问点位置在$B$3
可以循环判断后删除答
For Each P In xlSheet.Shapes
If P.Name Like "Picture*" and P.TopLeftCell.Address="$B$3" Then P.Delete
Next