【问题标题】:Is there a way to create excel worksheets out of a powerpoint presentation?有没有办法从 powerpoint 演示文稿中创建 excel 工作表?
【发布时间】:2019-08-20 15:32:52
【问题描述】:

我想从 powerpoint 演示文稿中创建 excel 工作表,我可以在其中保留 powerpoint 幻灯片的格式并能够调整某些值。有人知道方法吗?

我听说从 excel 工作表中创建 powerpoint 幻灯片,但我需要反过来,因为我想保持 powerpoint 幻灯片的格式,但需要能够调整某些值。有人知道方法吗?

我基本上需要一个看起来和工作起来都像我的 powerpoint 幻灯片的 Excel 工作表。

这是我目前所拥有的:

Dim PowerPointApp As Object
Dim myPresentation As Object
.
.
.
'Adds a slide to the presentation - is this also possible for worksheets?
 Set mySlide = myPresentation.slides.Add(myPresentation.slides.Count + 1, 11) '11 = ppLayoutTitleOnly   

' Pastes the copied range out of the excel into the Powerpoint
  mySlide.Shapes.PasteSpecial DataType:=2    
.
.
.

我想做的是把这些转过来,我找不到任何提示。无论是在书上还是在互联网上。

【问题讨论】:

  • 您的问题的答案是。到目前为止,您尝试过什么? SO 可以帮助解决特定的编码问题,但不是为您提供代码的服务。
  • 我添加了我目前使用的内容。

标签: excel vba powerpoint


【解决方案1】:

这是一个基本的方法。此代码在 Excel 中运行,需要对 powerpoint 对象库的引用。它在 Excel 中创建一个新工作表,每张幻灯片一个,并复制幻灯片内容(即所有形状)。它根据形状在幻灯片上的位置定位形状。有点概念启动器。干杯。

Option Explicit

' ---> ADD REFERENCE TO MICROSOFT POWERPOINT OBJECT LIBRARY

Public Sub CreateSheetsFromSlides()

    Dim vPowerPoint As PowerPoint.Application
    Dim vPresentation As PowerPoint.Presentation
    Dim vSlide As PowerPoint.Slide
    Dim vPowerpointShape As PowerPoint.Shape

    Dim vExcelShape
    Dim vSheet As Worksheet

    ' Open the powerpoint presentation
    Set vPowerPoint = New PowerPoint.Application
    Set vPresentation = vPowerPoint.Presentations.Open("source.pptx")

    ' Loop through each powerpoint slide
    For Each vSlide In vPresentation.Slides

        ' Create a new worksheet ... one per slide ... and name the worksheet same as the slide
        Set vSheet = ThisWorkbook.Sheets.Add(, After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
        vSheet.Name = vSlide.Name
        MsgBox vSheet.Name

        ' Loop through each shape on the powerpoint slide and copy to the new worksheet
        For Each vPowerpointShape In vSlide.Shapes
            vPowerpointShape.Copy

            ' Create the shape on the worksheet and position it on the sheet at the same top/left as it is on the slide
            vSheet.PasteSpecial
            Set vExcelShape = vSheet.Shapes(vSheet.Shapes.Count)
            vExcelShape.Top = vPowerpointShape.Top
            vExcelShape.Left = vPowerpointShape.Left
        Next
    Next
    vPresentation.Close
    vPowerPoint.Quit

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    相关资源
    最近更新 更多