[英]Powerpoint VBA to insert images based on a file path contained in the slide
我每個月都會制作一份冗長的PowerPoint報告。 每張幻燈片都有一個文本框,其中包含指向不同圖像文件的文件路徑。 是否有一個簡單的VBA可以引用這些文件路徑,並將其替換為關聯的映像? 非常感謝任何支持。
只需將代碼分解為以下網址 : http : //social.msdn.microsoft.com/Forums/en-US/245c1ee3-0731-4ef5-b934-fea5291b3b7b/vba-how-do-i-pass-the-text-in- a-powerpoint-text-box-into-a-variable-in-excel?forum = isvvba http://support.microsoft.com/KB/168649
我不知道您如何運行它,因此我沒有將其包含在sub
但是您仍然需要更改要打開的演示文稿以及正確的幻燈片和形狀。 我建議將其放在Module
並同時將slideNo As Integer, shapeNo As Integer, fileName as String
傳遞參數。
Dim oPP As PowerPoint.Application
Dim oPPT As Presentation
Dim oShp As Shape
Dim sText As String
Set oPP = New PowerPoint.Application
Set oPPT = ActivePresentation
Set oPPT = oPP.Presentations.Open("c:\sample.ppt")
Set oShp = oPPT.Slides(1).Shapes(3)
sText = oShp.TextFrame.TextRange.Text
Dim oSlide As Slide
Dim oPicture As Shape
ActiveWindow.View.GotoSlide 1
Set oSlide = ActiveWindow.Presentation.Slides(1)
Set oPicture = oSlide.Shapes.AddPicture(sText, _
msoFalse, msoTrue, 1, 1, 1, 1)
oPicture.ScaleHeight 1, msoTrue
oPicture.ScaleWidth 1, msoTrue
With ActivePresentation.PageSetup
oPicture.Left = (.SlideWidth \ 2) - (oPicture.Width \ 2)
oPicture.Top = (.SlideHeight \ 2) - (oPicture.Height \ 2)
oPicture.Select
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.