vba 通过嵌入在 excel 模板中的文件,以编程方式将图片设置为 powerpoint 背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6902181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Programmatically set a picture as a powerpoint background through file embedded on an excel template
提问by isJustMe
I'm generating a PPT presentation through vba in excel, everything is working just fine except that Im being asked to automatically set background of the power point (which it wouldn't be much a problem) but this will be done with a picture that is actually embedded on the macro, so I dont have physical path to reference the picture, plus the excel is generated on the fly according to the user inputs.
我正在通过 excel 中的 vba 生成 PPT 演示文稿,一切正常,除了我被要求自动设置电源点的背景(这不会有太大问题),但这将使用图片完成实际上嵌入在宏中,所以我没有引用图片的物理路径,而且excel是根据用户输入动态生成的。
so.. has anyone achieved this : Programmatically set a slide backrground from vba excel with a picture that is embedded on a sheet?
所以..有没有人做到了这一点:使用嵌入在工作表上的图片以编程方式从vba excel设置幻灯片背景?
Thanks!
谢谢!
采纳答案by Steve Rindsberg
If you can't find a way to set the background directly from a picture in memory, what about copy/pasting the picture from Excel into the Slide Master(s) in your PPT presentation then sending them to the back so they sit behind everything. The effect would be nearly identical from the user's point of view, I think.
如果您找不到直接从内存中的图片设置背景的方法,如何将图片从 Excel 复制/粘贴到 PPT 演示文稿中的幻灯片母版中,然后将它们发送到后面,以便它们位于所有内容的后面. 我认为,从用户的角度来看,效果几乎相同。
回答by JMax
As far as i understand, you want to set the background of the slides in vba(it doesn't matter it is called from Excel).
据我了解,您想在 vba 中设置幻灯片的背景(从 Excel 调用它无关紧要)。
Let's assume you have the path in a var:
假设您在 var 中有路径:
Dim osld As Slide
Set osld = ActivePresentation.Slides.Range 'every slides of the presentation
'This is important in some cases
osld.FollowMasterBackground = False
With osld.Background.Fill
.UserPicture <string var containing path to image>
End With
End Sub
You will also have to adapt ActivePresentation
with the PPT object you built from your previous code.
您还必须适应ActivePresentation
从以前的代码构建的 PPT 对象。