简体   繁体   中英

Is it possible to check if a slide in one PowerPoint presentation is the same as a slide in another deck?

I need to be able to determine whether (some) slides in two presentations are identical. Essentially a master presentation is updated every month and the previous version archived. The slide order remains the same, just the content of those slides may have changed. The trouble is...

deck1.Slides(i)=deck2.Slides(i)

...doesn't work, and ...

deck1.Slides(i).SlideID=deck2.Slides(i).SlideID

...returns identical values even if the slide content has changed.

I was wondering whether it is possible to checksum slides, but I haven't found anything online that would accomplish this -- the VBA checksum routines I've come across including on here are for text strings only. Is it possible to checksum slides or objects, or am I missing something obvious?

While this is by no means a ready-to-deploy solution, this might provide a starting point, provided your specific task is to check for changed text-contents in seemingly identical presentations.

I narrowed this down to comparing the text-contents of Textboxes (shape-type 14) on Slide 1 for this demonstration.

Sub Neu()
    Dim ppt As New PowerPoint.Application

    Dim i As Integer, j As Integer        
    i = 1
    For j = 1 To ppt.Presentations(1).Slides(i).Shapes.Count

        If ppt.Presentations(1).Slides(i).Shapes(j).Type = 14 And _
            Presentations(2).Slides(i).Shapes(j).Type = 14 Then _            
                Debug.Print _
                    ppt.Presentations(1).Slides(i).Shapes(j).TextFrame.TextRange.Text = _
                    Presentations(2).Slides(i).Shapes(j).TextFrame.TextRange.Text

    Next j
End Sub

General Notes:

  • This obviously doesn't account for changed formats or placings.
  • I would expect some trouble as soon as there are new Shapes added to one of the Slides.
  • Afaik, when adding a new shape it should have Shape(Index) = Shapes.Count+1 , but you never know what people do to your presentation...

Hopefully, someone comes up with a more elegant approach to solving this!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM