|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST1()
Dim ar, i&, strFileName As String, strPath$, strSavePath$, dWidth$, dHeight$
strPath = ThisWorkbook.Path & "\生成图片文件夹\"
If Dir(strPath, vbDirectory) = "" Then MkDir strPath
With Worksheets(1)
With .[A1].CurrentRegion
ar = .Value
For i = 1 To 10 Step 2
strSavePath = strPath & ar(i + 1, 3) & "\"
If Dir(strSavePath) = "" Then MkDir strSavePath
strFileName = strSavePath & ar(i + 1, 3) & ".jpg"
With .Cells(i, 1).Resize(2, UBound(ar, 2))
dWidth = .Width: dHeight = .Height
.CopyPicture xlScreen, xlPicture
End With
With .Parent.ChartObjects.Add(0, 0, dWidth, dHeight)
With .Chart
.Parent.Select
.Paste
.ChartArea.Format.Line.Visible = msoFalse
.PlotArea.Format.Line.Visible = msoFalse
.ChartArea.Fill.Visible = msoFalse
.PlotArea.Fill.Visible = msoFalse
.Export Filename:=strFileName
End With
.Delete
End With
Next i
End With
End With
Beep
End Sub
|
|