[英]Exporting data from Excel to an existing PowerPoint slide using VBA
[英]Excel VBA to Powerpoint: Copying a cell to textbox in an existing slide
我是开始擅长将vba导出并控制信息到其他程序的Excel。
任务:需要印刷铭牌,并将其分发给人员以标记其设备。 我们有一个庞大的设备主列表,必要的信息(机器ID)仅在excel工作表的一栏中。 不干胶标签的模板在PowerPoint中。
这些步骤是:
PowerPoint应该打开模板
Excel应将一张信息的单元格放到一张幻灯片中。
到目前为止,这是我的代码:
Sub Sammple()
'Declaring Variables
Dim TemplateName As String
Dim pptpres As Object
Dim mySlide As Object
Dim myPresentation As Presentation
Dim TextBox As Object
Dim i As Integer
Dim j As Integer
Set pptpres = CreateObject("Powerpoint.Application")
With pptpres
.Visible = True
.Presentations.Open ("FileNameHere")
For i = 1 To 400
.ActivePresentation.Slides(1).Duplicate.Item (1)
Next
For j = 3 To 514
Cells(j, 4).Copy
Next
End With
End Sub
如您所知,我已经将Excel的代码下载下来,可以制作400张重复的幻灯片。 我不太明白如何使excel将文本从单元格复制到文本框并转换为powerpoint,然后一遍又一遍地进行直到到达列范围的末尾。
指向正确方向的任何帮助都将非常有用。 您将为我节省超过1000次复制和粘贴点击。
您是说以下意思吗?
复制了已经定义了文本框的PP幻灯片后,是否要将excel单元格的值填写到PP幻灯片的文本框中?
也就是说,如果每个幻灯片中的文本框都具有相同的名称,则可以转到Powerpoint进行检查,选择对象(文本框),再转到“格式”,“选择窗格”,然后在其中可以看到文本框的名称。 在这种情况下,它是“标题1”
Dim pp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.slide
Set pp = CreateObject("PowerPoint.Application")
Set PPPres = pp.Presentations.Open ("Filenamehere")
Set PPSlide = PPPres.Slides.Add(Slidestart, ppLayoutTitleOnly)
Sheets("SHEET NAME OF EXCEL").Activate
PPSlide.Shapes("Title 1").TextFrame.TextRange.Text = cells(i,j).text
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.