|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如果已经存在200张表且有内容了。那只能插入图片
设置单元格和图片宽高的代码如不需要可删除。
- Sub cr()
- Dim ws As Worksheet
- Dim picObj As Shape
- Dim picPath As String
- picPath = "" ' 图片路径和文件名
-
- For Each ws In ThisWorkbook.Worksheets
- Set picObj = ws.Shapes.AddPicture(picPath, msoFalse, msoTrue, ws.Range("A1").Left, ws.Range("A1").Top, ws.Range("A1").Width, ws.Range("A1").Height)
- '更改A1单元格长宽
- With ws.Range("A1")
- .ColumnWidth = 20
- .RowHeight = 50
- End With
- '更改图片长宽,并居中
- With picObj
- .LockAspectRatio = msoFalse
- .Width = 35
- .Height = 35
- .Left = (ws.Range("A1").Width - .Width) / 2 + ws.Range("A1").Left
- .Top = (ws.Range("A1").Height - .Height) / 2 + ws.Range("A1").Top
- End With
- Next ws
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|