看到论坛上有会员提问如何把工作表区域另存为图片,兰色研究了一个小时,终于把代码完成,希望大家喜欢。 Sub SheetOutJpg() Dim Newshape As Shape Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture ActiveSheet.Paste Set Newshape = ActiveSheet.Shapes(ActiveSheet.Shapes.Count) With ActiveSheet.ChartObjects.Add(1, 1, 1, 1) .Width = Newshape.Width .Height = Newshape.Height Newshape.Copy .Chart.Paste .Chart.Export ActiveWorkbook.Path & "\Myjpg.jpg" .Delete End With Newshape.Delete MsgBox "恭喜!图片已生成并存放在" & ActiveWorkbook.Path End Sub
|