Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 16871|回复: 39

[分享] 兰色原创:工作表中选取区域另存为图片的代码

[复制链接]
发表于 2007-8-30 18:20 | 显示全部楼层 |阅读模式

   看到论坛上有会员提问如何把工作表区域另存为图片,兰色研究了一个小时,终于把代码完成,希望大家喜欢。

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


发表于 2007-8-30 18:36 | 显示全部楼层
回复

使用道具 举报

发表于 2007-8-30 18:39 | 显示全部楼层
回复

使用道具 举报

发表于 2007-8-30 19:02 | 显示全部楼层

执行不了,中断如黄色部分

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

回复

使用道具 举报

发表于 2007-8-31 01:04 | 显示全部楼层

我弄一个礼拜也弄不出来,加精不过分。[em02]
回复

使用道具 举报

发表于 2007-8-30 19:04 | 显示全部楼层

先下载

  谢谢兰版

回复

使用道具 举报

 楼主| 发表于 2007-8-30 19:06 | 显示全部楼层

QUOTE:
以下是引用swordin在2007-8-30 19:02:35的发言:

执行不了,中断如黄色部分

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

提示什么错误啊,我这里没有问题

回复

使用道具 举报

发表于 2007-8-30 19:06 | 显示全部楼层

刚刚试完

  我的也没问题

 

回复

使用道具 举报

发表于 2007-8-30 19:12 | 显示全部楼层

谢谢.
回复

使用道具 举报

发表于 2007-8-30 20:37 | 显示全部楼层

谢谢兰版,测试成功!

 


[此贴子已经被作者于2007-8-30 20:37:46编辑过]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-19 22:04 , Processed in 0.319679 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表