将 Excel 数据转换为 PowerPoint 幻灯片

nqw*_*qw1 6 automation macros microsoft-powerpoint microsoft-excel-2011

我已经找到了一些有用的网站,但我仍然无法做我想做的事。我的 Excel 文件包含几列和多行。来自一行的所有数据都将在一张幻灯片中,但来自该行中不同单元格的数据应转到 PP 幻灯片中的特定元素。首先,是否可以将Excel单元格中的数据导出到PP中的特定文本框?例如,我想让每一行第一列的所有数据都转到文本框 1。假设我有 100 行,所以我有 100 张幻灯片,每张幻灯片都有带有正确数据的文本弓 1。幻灯片 66 的文本框将包含来自第 66 行第一列的数据。然后来自每行第二列的所有数据将转到文本框 2,依此类推。

我尝试做一些宏,但没有成功。我还尝试使用 Word 大纲并将它们导出到 PP(新幻灯片 -> 大纲中的幻灯片),但似乎有一个错误,因为我收到了 250 页的胡言乱语。我只有两段,而且都只有一个词。第一段使用标题 1 样式,第二段使用普通样式。

我发现的网站,使用 VB 和/或其他一些编程语言从 Excel 工作表创建幻灯片。我曾尝试将这些 VB 代码添加到我的宏中,但到目前为止它们都没有起作用。可能我只是不知道如何正确使用它们 :) 这里有一些有用的网站:

VBA:为 Excel 工作簿中的每一行创建 PowerPoint 幻灯片

创建基于数据的演示报告

Stackoverflow 中的问题

我在 Mac 上使用 Office 2011。任何帮助,将不胜感激!

小智 3

尝试这样的事情。我制作了一些模组,以便用工作表中的值替换幻灯片上文本 @COL1@ 的任何实例。请注意,未经测试的航空代码。

Sub CreateSlides()
'Open the Excel workbook. Change the filename here.
Dim OWB As New Excel.Workbook
Set OWB = Excel.Application.Workbooks.Open("C:\list.xlsx")
'Grab the first Worksheet in the Workbook
Dim WS As Excel.Worksheet
Dim sCurrentText As String
Dim oSl As Slide
Dim oSh As Shape
Set WS = OWB.Worksheets(1)
Dim i As Long
'Loop through each used row in Column A
For i = 1 To WS.Range("A65536").End(xlUp).Row
    'Copy the first slide and paste at the end of the presentation
    ActivePresentation.Slides(1).Copy
    Set oSl = ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count + 1)
    sCurrentText = WS.Cells(i, 1).Value

    ' find each shape with "@COL1@" in text, replace it with value from worksheet
    For Each oSh In oSl.Shapes
      ' Make sure the shape can hold text and if is, that it IS holding text
      If oSh.HasTextFrame Then
        If oSh.TextFrame.HasText Then
          ' it's got text, do the replace
          With oSh.TextFrame.TextRange
            .Replace "@COL1@", sCurrentText
          End With
        End If
      End If
    Next
Next
End Sub
Run Code Online (Sandbox Code Playgroud)