PDA

View Full Version : Copy Slide



bwells
08-02-2006, 12:39 PM
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

TrippyTom
08-02-2006, 02:24 PM
Does it matter where you insert the slides (before or after the current slide, or at the beginning of the doc, or the end)?

TrippyTom
08-02-2006, 03:04 PM
Here's my example:

My form code:

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


Procedure Code:

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

bwells
08-03-2006, 05:57 AM
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.

bwells
08-03-2006, 07:05 AM
Hey TrippyTom. Thanks for the help. I only use this line of code

ActiveWindow.View.GotoSlide Index:=ActiveWindow.Selection.SlideRange.Duplicate.SlideIndex

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.

TrippyTom
08-03-2006, 08:11 AM
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? :dunno

bwells
08-03-2006, 08:49 AM
Thats alright. I'm learning powerpoint vba as well.

Well what i did was I changed that line of code

from:

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

to:

For counter = 0 To answer - 1
ActiveWindow.View.slide.duplicate
Next


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.