簡體   English   中英

在 PowerPoint 演示文稿中復制幻燈片

[英]Duplicating a slide in PowerPoint presentation

如何使用 Excel VBA 復制特定幻燈片?

干得好:

ActivePresentation.Slides(1).Duplicate

這將復制並移動幻燈片 1:

Sub Duplicate_And_Move_Slide()

    Dim oPPT As Object
    Dim oPresentation As Object
    Dim oSlide As Object

    Set oPPT = CreatePPT
    Set oPresentation = oPPT.presentations.Open( _
        "<full path to your PP Presentation")

    With oPresentation.slides(1)
        .Duplicate
        .MoveTo 3
    End With

End Sub

'----------------------------------------------------------------------------------
' Procedure : CreatePPT
' Purpose   : Creates an instance of Powerpoint and passes the reference back.
'-----------------------------------------------------------------------------------
Public Function CreatePPT(Optional bVisible As Boolean = True) As Object

    Dim oTmpPPT As Object

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Defer error trapping in case PowerPoint is not running. '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    On Error Resume Next
    Set oTmpPPT = GetObject(, "PowerPoint.Application")

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'If an error occurs then create an instance of PowerPoint. '
    'Reinstate error handling.                                 '
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    If Err.Number <> 0 Then
        Err.Clear
        On Error GoTo ERROR_HANDLER
        Set oTmpPPT = CreateObject("PowerPoint.Application")
    End If

    oTmpPPT.Visible = bVisible
    Set CreatePPT = oTmpPPT

    On Error GoTo 0
    Exit Function

ERROR_HANDLER:
    Select Case Err.Number

        Case Else
            MsgBox "Error " & Err.Number & vbCr & _
                " (" & Err.Description & ") in procedure CreatePPT."
            Err.Clear
    End Select

End Function

暫無
暫無

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

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