簡體   English   中英

從Excel創建PowerPoint演示文稿

[英]Create PowerPoint presentation from Excel

我正在嘗試從Excel電子表格制作PP幻燈片。 我有這個VBA模塊:

     Sub CreatePowerPointQuestions()
    Dim newPowerPoint As PowerPoint.Application
    Dim activeSlide As PowerPoint.Slide
    Dim Question As String
    Dim Options As String
    Dim Answer As String
    Dim limit As Integer

    limit = 3
    On Error Resume Next
Set newPowerPoint = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If newPowerPoint Is Nothing Then
    Set newPowerPoint = New PowerPoint.Application
End If

   'Make a presentation in PowerPoint
  If newPowerPoint.Presentations.Count = 0 Then
    newPowerPoint.Presentations.Add
  End If

'Show the PowerPoint
newPowerPoint.Visible = True
'Select worksheet and cells activate
Worksheets("Sheet1").Activate

'Loop through each question
For i = 1 To limit

'Add a new slide where we will paste the Question and Options:
    newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, 3
    newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
    Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)

'Set the variables to the cells
    Question = ActiveSheet.Cells(i, 1).Value
    Options = ActiveSheet.Cells(i, 2).Value
    Answer = ActiveSheet.Cells(i, 3).Value


    activeSlide.Shapes(1).TextFrame.TextRange.Text = Question
    activeSlide.Shapes(2).TextFrame.TextRange.Text = Options

    activeSlide.Shapes(3).TextFrame.TextRange.Text = Answer

Next


Set activeSlide = Nothing
Set newPowerPoint = Nothing



End Sub

問題在於它創建的幻燈片帶有標題,兩個條目與項目符號並排。 我希望幻燈片是三行,沒有項目符號。 有沒有辦法做到這一點? 我不知道該怎么做

您可以在https://msdn.microsoft.com/zh-cn/library/office/ff745137.aspx上使用布局列表。

但是,其中只有兩個符合您的條件

  • ppLayoutObjectOverText,和
  • ppLayoutTextOverObject

Set activeslide行之后嘗試以下操作:

    activeSlide.layout = ppLayoutObjectOverText

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM