Sub exportPic()
For K = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Sheets(1).Cells(K, 1).CopyPicture
Set CHT = ActiveSheet.ChartObjects.Add(0, 0, Cells(K, 1).Width, Cells(K, 1).Height).Chart
With CHT
.Paste
.Export "d:\" & Cells(K, 1) & ".JPG"
.Parent.Delete
End With
Next K
set CHT=NOTHING
End Sub
用这个代码输出的图片是空白的,没有单元格内的文字
For K = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Sheets(1).Cells(K, 1).CopyPicture
Set CHT = ActiveSheet.ChartObjects.Add(0, 0, Cells(K, 1).Width, Cells(K, 1).Height).Chart
With CHT
.Paste
.Export "d:\" & Cells(K, 1) & ".JPG"
.Parent.Delete
End With
Next K
set CHT=NOTHING
End Sub
用这个代码输出的图片是空白的,没有单元格内的文字
如果你要把文字输出到图片上,你必须使用Picture对象来处理这张图片,打印上文字以后再保存。
Dim K As Long
For K = 1 To Cells(Rows.Count, 1).End(xlUp).Row
Sheets(1).Cells(K, 1).CopyPicture
Dim CHT As Chart
Set CHT = ActiveSheet.ChartObjects.Add(0, 0, Cells(K, 1).Width, Cells(K, 1).Height).Chart
With CHT
.Paste
DoEvents
.Export "d:\" & Cells(K, 1) & ".JPG"
.Parent.Delete
End With
Next K
Set CHT = Nothing
End Sub运行示例: