|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub shpFill()
- Dim myPath$, shp As Shape
- Dim arr, brr
- arr = Array("1", "2", "3", "4")
- brr = Array("6", "12", "18", "24")
- For i = 0 To UBound(arr)
- Set shp = ActiveSheet.Shapes(arr(i))
- Application.ScreenUpdating = False
- shp.Copy '复制图形
- ActiveSheet.Paste '粘贴图形
- With Selection '去边框后复制
- .ShapeRange.Line.Visible = msoFalse
- .Copy
- .Delete
- End With
- myPath = ThisWorkbook.Path & "\myPic.jpg" '文件保存路径
- '创建图表,大小同shp
- With ActiveSheet.ChartObjects.Add(0, 0, shp.Width, shp.Height).Chart
- .Paste
- .Export myPath '另存jpg文件
- .Parent.Delete
- End With
- ActiveSheet.Shapes(brr(i)).Fill.UserPicture myPath '文件填充
- Kill myPath '删除jpg文件
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|