通过嵌入在Excel模板上的文件以编程方式将图片设置为powerpoint背景

时间:2021-01-09 13:00:57

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设置一个幻灯片backrground与嵌入在工作表上的图片?

Thanks!

谢谢!

2 个解决方案

#1


1  

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演示文稿中的幻灯片母版然后将它们发送到后面,这样他们就会坐在后面。我认为,从用户的角度来看,效果几乎相同。

#2


4  

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.

您还必须使用从先前代码构建的PPT对象来调整ActivePresentation。

#1


1  

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演示文稿中的幻灯片母版然后将它们发送到后面,这样他们就会坐在后面。我认为,从用户的角度来看,效果几乎相同。

#2


4  

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.

您还必须使用从先前代码构建的PPT对象来调整ActivePresentation。