使用VBA在PowerPoint中插入/更新图像? [英] Using VBA to insert/update image in PowerPoint?
问题描述
我正在制作一个交互式Powerpoint演示文稿,该演示文稿先前已从我的本地服务器(XAMPP)读取文本文件并显示它。我现在想更新它,以便用户可以手写他们的响应,并在幻灯片中显示。我有一个jQuery插件,允许有人使用手写笔,它将绘图保存为本地服务器上的图像。
I am making an interactive Powerpoint presentation that has previously read a text file from my local server (XAMPP) and displayed it. I'd like to now update it so that the user can hand-write their response, and it displays that on the slideshow. I have a jQuery plugin that lets someone use a stylus and it saves the 'drawing' as an image on the local server.
我的问题是,如何插入使用VBA宏将图像转换为PowerPoint?或者由于图像始终具有相同的文件路径,但将被替换为不同的图像,我可以以某种方式更新幻灯片上的图像吗?对不起,如果它令人困惑。
My question is, how can I insert the image into PowerPoint using a VBA Macro? Or since the image always will have the same file path, but will be replaced with a different image, can I somehow "Update" the image on the slide? Sorry if it's confusing.
这是我试过的VBA:
Sub insert()
Dim oPic As Shape
Set oPic = ActivePresentation.Slides(1).Shapes.AddPicture("http://localhost/image.png", False, True, 0, 0, -1, -1)
End Sub
我也可以得到的路径计算机上的图像,而不是服务器。
I could also get the path of the image on the computer, not the server.
当我运行宏时,我收到找不到文件错误。有谁知道什么是错的?
When I run the macro, I get a "file not found" error. Does anyone know what's wrong?
谢谢!
PS:如果有人有兴趣,插件名为签名垫。
PS: If anyone's interested, the plugin is called Signature Pad.
推荐答案
看起来我可以插入一个图像,如果它在完全相同的文件夹中:
Looks like I can insert an image if it's in the exact same folder:
Sub insert()
Dim oPic As Shape
Set oPic = ActivePresentation.Slides(1).Shapes.AddPicture("image.png", False, True, 0, 0, -1, -1)
End Sub
这有效,但如果有人知道如何进入另一个文件夹,请告诉我。如果我尝试 folder / image.png
或 /folder/image.png
作为文件路径,它不会工作。
This works, but if anyone knows how to go into another folder, please let me know. If I try folder/image.png
or /folder/image.png
as the file path, it doesn't work.
这篇关于使用VBA在PowerPoint中插入/更新图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!