|
把图片5个一组保存到文件夹里,现在一列一列的保存,怎么改成一行一行的保存图片
Sub 保存图片()
Dim ad$, m&, wz&, mc$, Shp As Shape
Dim nm$, n&, myFolder$
Sheet1.Activate
n = 0
Z = 1
myFolder = ThisWorkbook.Path & "\图片\" '指定文件夹名称
For Each Shp In ActiveSheet.Shapes
If Shp.Type = 13 Then
If Len(Dir(myFolder, vbDirectory)) = 0 Then
MkDir myFolder
End If
n = n + 1
If (n - 1) / 5 + 1 = Z Then
If Len(Dir(myFolder & Format(Z, "00"), vbDirectory)) = 0 Then
MkDir myFolder & Format(Z, "00")
End If
Z = Z + 1
End If
'ad = shp.TopLeftCell.Address
m = Shp.TopLeftCell.Row
wz = Shp.TopLeftCell.Column
mc = Replace(Cells(m, wz - 2).Value & "-" & Cells(m, wz - 1).Value, "$", "")
nm = Format(n, "00") & "-" & mc & ".jpg" '图形对象的名字
Shp.CopyPicture '将图形对象复制到剪切板
With ActiveSheet.ChartObjects.Add(0, 0, Shp.Width, Shp.Height).Chart '在工作表中添加一个图表对象
.Parent.Select
.Paste '代码将剪切板中的图形对象以图片的格式粘贴到新添加的图表中
.Export myFolder & Format(Z - 1, "00") & "\" & Format(Z - 1, "00") & "-" & nm, "JPG"
.Parent.Delete '删除工作表中添加的图表对象
End With
'Range(ad) = nm
End If
Next
End Sub
|
|