Consulting

Results 1 to 6 of 6

Thread: Solved: Add presentation to current with slide index

  1. #1
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    5
    Location

    Solved: Add presentation to current with slide index

    Hi,

    i currently use the following macro to add slides to my presentation from other presentations

    [VBA]Sub FI_EconomicUpdate()

    If ActiveWindow.Selection.Type = ppSelectionNone Then
    ActiveWindow.ViewType = ppViewSlide
    ActiveWindow.ViewType = ppViewSlideSorter

    If ActiveWindow.Selection.Type = ppSelectionSlides Then
    CurrentSlideIndex = ActiveWindow.Selection.SlideRange.SlideIndex
    ActivePresentation.Slides.InsertFromFile _
    "S:\FILENAME.ppt", CurentSlideIndex, 1, Last
    ActiveWindow.ViewType = ppViewNormal
    Else
    CurrentSlideIndex = 0 ' no slides
    End If
    Else
    CurrentSlideIndex = ActiveWindow.Selection.SlideRange.SlideIndex
    End If[/VBA]

    I want to use this same macro for adding another presentation (Pres A) into my current presentation (Pres B) - However Pres A changes in size from month to month and thus the slide index will always need changing - is there a work around?

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    It's not at all clear what the problem is.

    Are you adding the slides in Slide Sorter View?
    Are you adding ALL the slides from B (this is the default)

    Last in your code must refer to something you have not attached but it is almost certainly not required.

    Maybe this:

    [vba]Sub FI_EconomicUpdate()
    Dim CurrentSlideIndex As Long
    'makes sure that a slide is selected (not cursor between slides)
    ActiveWindow.ViewType = ppViewSlideSorter
    ActiveWindow.ViewType = ppViewNormal

    'Adds all slides at cursor position
    CurrentSlideIndex = ActiveWindow.View.Slide.SlideIndex
    ActivePresentation.Slides.InsertFromFile "S:\FILENAME.ppt", Index:=CurrentSlideIndex
    End Sub[/vba]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    5
    Location
    works. Thanks!

  4. #4
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    5
    Location
    hi,

    im now using 2010 and the CurrentSlideIndex doesnt seem to work, any solutions available?

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    I can confirm that I see this too. It SHOULD work AFAIK and I will report it as a bug.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    EDIT

    I take it back. The file path I was adding was incorrect. It works perfectly in 2010 here.

    This is a little more robust

    [vba]Sub FI_EconomicUpdate()
    Dim CurrentSlideIndex As Long
    Dim osld As Slide
    On Error Resume Next
    'makes sure that a slide is selected (not cursor between slides)
    ActiveWindow.ViewType = ppViewSlideSorter
    ActiveWindow.ViewType = ppViewNormal
    Set osld = ActiveWindow.View.Slide
    'Adds all slides at cursor position
    If Not osld Is Nothing Then
    CurrentSlideIndex = osld.SlideIndex

    ActivePresentation.Slides.InsertFromFile "S:\FILENAME.ppt", Index:=CurrentSlideIndex
    Else
    MsgBox "Select a slide!!"
    End If
    End Sub[/vba]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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