将 Web 中的图片添加到 VBA (MacOS) 中的 Powerpoint 幻灯片 [英] Adding pictures from the Web to a Powerpoint slide in VBA (MacOS)

查看:51
本文介绍了将 Web 中的图片添加到 VBA (MacOS) 中的 Powerpoint 幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很舒服地使用 VBA 遍历 Excel 电子表格中的内容列表,并在单独的 Powerpoint 文件中创建幻灯片.这一点有效.

I'm comfortably using VBA to iterate through a list of content in an Excel spreadsheet and creating slides in a separate Powerpoint file. That bit works.

但是我似乎无法向 Powerpoint 演示文稿添加图片.我试过了:

However I can't seem to add pictures to the Powerpoint presentation. I've tried:

  • Using Shapes.AddPicture with an URL to the image. A few mention this should work; apparently it broke in some Office version (see http://www.pcreview.co.uk/forums/powerpoint-2007-vba-addpicture-web-image-problem-t3171074.html);
  • Using Shapes.AddPicture with the path to a file. This should work, but:

暗图
Set pic = activeSlide.Shapes.AddPicture("/Users/Pedro/My_Picture.png", False, True, 10, 10)

...失败,出现运行时错误 5(无效的过程调用或参数).请注意,我使用的是 Mac OS X、Office 2011.

...fails with a Runtime Error 5 (invalid procedure call or argument). Please note I'm on Mac OS X, Office 2011.

我也尝试过通过 UserPicture() 设置对象的填充无济于事.

I've also tried setting the Fill of an object via UserPicture() to no avail.

在此先感谢您的帮助!

推荐答案

这适用于 Windows 版本的 PPT,但在 Mac 2011 中失败:

This works on Windows versions of PPT but fails in Mac 2011:

Sub thing()
Dim oPic As Shape
Set oPic = ActivePresentation.Slides(1).Shapes.AddPicture("http://www.somesite.xxx/directory/filename.jpg", False, True, 0, 0, -1, -1)
End Sub

不幸的是,相当多的应该工作(并在 Win 版本中)在 Mac PPT 中失败了.

Quite a few things that should work (and do in the Win versions) fail in Mac PPT, unfortunately.

最后两个 -1 参数告诉 PPT 以自然"大小导入图片......即,如果您手动插入图像,它通常会插入任何大小;这样可以避免图像失真.

The last two -1 parameters tell PPT to bring the picture in at "natural" size ... ie, whatever size it'd normally insert the image if you did it manually; this avoids distorting the image.

这篇关于将 Web 中的图片添加到 VBA (MacOS) 中的 Powerpoint 幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆