将图表从 Excel 复制到 PowerPoint,保持质量和透明度

发布于 2024-12-26 10:55:10 字数 1348 浏览 0 评论 0原文

我正在编写一个宏来复制 Excel 图表并将其作为透明图片粘贴到 PowerPoint 演示文稿中。到目前为止听起来很简单,但问题是图片要么不透明,要么扭曲。

请看一下:

  • 这是执行宏后得到的扭曲版本:

 Distorted:

  • 这是我手动复制时得到的结果/粘贴它(这就是我希望它的样子):

desired:

我的代码(相关部分):

ActiveSheet.ChartObjects("MyChartNameGoesHere").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
PPSlide.Shapes.PasteSpecial(ppPasteEnhancedMetafile).Select

我尝试将 CopyPicture 格式参数从 xlPicture 更改为 xlBitmap 但在这种情况下,图片不透明并覆盖幻灯片背景。而且我不确定它看起来是否顺利。

我还尝试将幻灯片的 PasteSpecial 参数更改为几乎每个列出的 此处 仍然没有成功。

一段时间以来,我相信 xlBitmap 版本是好的,只是不透明。这就是为什么我将两个示例移到幻灯片的边缘,以便我们可以看到。但放大后我发现它也扭曲了。我不知道我是否真的犯了错误,或者我只是不小心从代码中删除了一些重要的东西(很可能)。通过记忆恢复到以前的版本但失败。

再次,当我从 Excel 复制图表并手动将其作为图片特殊粘贴到 PowerPoint 时,一切都很好。 PowerPoint 2007 没有宏记录器,因此我看不到发生了什么。

请帮帮我。任何想法都非常感激!

更新“扭曲”版本不仅......扭曲,而且“重”5倍(就演示文件大小而言)。任何帮助仍然非常感谢!

I'm coding a macros to copy an Excel chart and paste it to a PowerPoint presentation as a transparent picture. Sounds simple so far, but the problem is that the picture is either not transparent or distorted.

Take a look please:

  • here's the distorted version I get after executing my macros:

distorted:

  • here's what I get when I manually copy/paste it (and that's how I want it to look like):

desired:

My code (the relevant part):

ActiveSheet.ChartObjects("MyChartNameGoesHere").CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
PPSlide.Shapes.PasteSpecial(ppPasteEnhancedMetafile).Select

I've tried to change the CopyPicture format parameter from xlPicture to xlBitmap but in that case the picture is not transparent and overlays slide background. And I'm not sure it looks smooth.

I've also tried to change the slide's PasteSpecial parameter to almost each listed here and still no success.

For some time I believed that the xlBitmap version is OK and it's just not transparent. That's why I moved both examples to the edge of a slide so we can see that. But then after zooming in I realised it was distorted as well. I don't know whether I got really mistaken or I just accidentally dropped something important from my code (most likely). Restored by memory to the previous version but failed.

Once again, everything's fine when I copy chart from Excel and special-paste it to PowerPoint as a picture manually. PowerPoint 2007 doesn't have a macros recorder, so I can't see what's happening.

Please help me out. Any thoughts are mush appreciated!

UPDATE the "distorted" version is not only... distorted, but also 5 times "heavier" (in terms of a presentation file size). Any help still much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灰色世界里的红玫瑰 2025-01-02 10:55:10

我在工作中使用这段代码来绘制图表

For Each Grf In E.ActiveSheet.ChartObjects
    Grf.Copy
    Sld.Shapes.Placeholders(Nr).Select msoCTrue
    P.ActivePresentation.Windows(1).View.PasteSpecial (ppPasteMetafilePicture)
    Nr = Nr + 1
Next Grf

I use in my work this code to charts

For Each Grf In E.ActiveSheet.ChartObjects
    Grf.Copy
    Sld.Shapes.Placeholders(Nr).Select msoCTrue
    P.ActivePresentation.Windows(1).View.PasteSpecial (ppPasteMetafilePicture)
    Nr = Nr + 1
Next Grf
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文