Consulting

Results 1 to 7 of 7

Thread: Copy Slide

  1. #1

    Copy Slide

    Hey all. Does anyone know of anyway to copy and insert an entire slide using VBA? I want to have a form that allows the user to say ok i want 5 slides. Then, 4 are added to the deck. Does anyone have any ideas?


    Thank you


    Note: I've asked this question at: http://www.ozgrid.com/forum/showthread.php?t=55163

  2. #2
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    Does it matter where you insert the slides (before or after the current slide, or at the beginning of the doc, or the end)?
    Office 2010, Windows 7
    goal: to learn the most efficient way

  3. #3
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    Here's my example:

    My form code:
    [vba]
    Option Explicit
    Private Sub btn_cancel_Click()
    Unload Me
    End Sub
    Private Sub btn_OK_Click()
    On Error GoTo Nirvana
    If tb_answer > 0 Then
    myInsertSlides.myAnswer = tb_answer.Value
    Unload Me
    End If
    Nirvana:
    End Sub
    [/vba]

    Procedure Code:
    [vba]
    Option Explicit
    Public myAnswer As String
    Public Sub insertSlides()
    Dim i As Integer
    frm_InsertSlides.Show
    For i = 1 To myAnswer
    ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex
    Next i
    End Sub
    [/vba]
    Office 2010, Windows 7
    goal: to learn the most efficient way

  4. #4
    It does matter where i put it. I want it to be at the end of the deck.

    Heres what i'm doing..

    I have a menu that lists all the slides in a presentation. The user selects which slides they want. If a certain slide is selected i want some message/way of asking the user how many copies of this sldie do they need. I need to take that value and add the correct amount of copies of that slide.


    Hope that is not to confusing....let me know.

  5. #5
    Hey TrippyTom. Thanks for the help. I only use this line of code

    [VBA]ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex [/VBA]

    One Question, how do I do that same operation just without the GotoSlide. I want the view to stay on current sldie while duplicating so when the duplication is finish the user is at the same slide where they were asked the question.

    I can take a cheap way arond it, but there must be a more programatic way.

  6. #6
    VBAX Expert TrippyTom's Avatar
    Joined
    Jul 2005
    Location
    New York, NY (USA)
    Posts
    556
    Location
    Hmm... well I got that line from the macro recorder. It usually doesn't help at all in PowerPoint, but this time it actually gave me something to work with.

    I'm not sure about your second question; perhaps you could go back the same number of slides you inserted to get back to your original slide number? I'm still learning the VBA Object Model, so I don't know the answer.

    Hopefully someoneo else can help?
    Office 2010, Windows 7
    goal: to learn the most efficient way

  7. #7
    Thats alright. I'm learning powerpoint vba as well.

    Well what i did was I changed that line of code

    from:

    [VBA] For i = 1 To myAnswer
    ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex
    Next i [/VBA]

    to:

    [VBA] For counter = 0 To answer - 1
    ActiveWindow.View.slide.duplicate
    Next[/VBA]


    This addin works along with a special presentation, so nothign ever changes. So to get back, i just used the 'goto' function and put in the slide number. Cheap, but works. Like i said there must be a more programmatic way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •