简体   繁体   English

Power Point VBA - 将图片从用户窗体复制到幻灯片

[英]Power Point VBA - Copy Picture from Userform to Slide

Dear Fellow StackOverFlow-members,亲爱的 StackOverFlow 成员,

is there a possibility to copy a picture from an userform into a slide?是否有可能将图片从用户窗体复制到幻灯片中?

I've tried several approaches:我尝试了几种方法:

ActivePresentation.Slides(1).Shapes.AddPicture 'Filename has to be a string, thus i can't set the Userform as source ActivePresentation.Slides(1).Shapes.AddPicture '文件名必须是字符串,因此我不能将用户窗体设置为源

I've thought of something like frm_Userform.Image1.Picture to get somehow the picture, but I have no idea to set the picture within a slide.我想到了类似frm_Userform.Image1.Picture的东西来以某种方式获取图片,但我不知道将图片设置在幻灯片中。

The possibilties to pre-define a picture path is not possible as several users with different user rights are going to use the makro (add-in).由于多个具有不同用户权限的用户将使用 makro(加载项),因此无法预定义图片路径。

Are there maybe other possibilities to save a picture within an add-in and use (paste) it on slides?是否有其他可能性可以在加载项中保存图片并在幻灯片上使用(粘贴)它?

Thank you in advance!先感谢您!

Can you put the logo files in a known location?您可以将徽标文件放在已知位置吗? Then you can add them with something like:然后,您可以使用以下内容添加它们:

IconFile$ = AddinPath$ & "\YellowIcon.gif"
Set ShO = PresO.Slides(1).Shapes.AddPicture(FileName:=IconFile$, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=10, Height:=10)
With ShO
    .ScaleHeight 1, msoTrue
    .ScaleWidth 1, msoTrue
End With
Sub CopyFromUserFormToSlide

Const TempFolder = 2
Dim fso, path
Set fso = CreateObject("scripting.filesystemobject")
path = fso.GetSpecialFolder(TempFolder).Path & "\" & fso.GetTempName
SavePicture UserForm.Image1.Picture, path
ActivePresentation.Slides(1).Shapes.AddPicture path,msoFalse,msoTrue,150,150
fso.DeleteFile path

End Sub

This did the job for me.这为我完成了工作。 Excel solution was on stack and had to adjust it to PowerPoint. Excel 解决方案在堆栈中,必须将其调整为 PowerPoint。 Thank you anyway!还是非常感谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM