Embedded PPT in my PPT?

D

David C. Johnson

Hello,

Ive been trying to remove the embedded PPT show(s) from the master slide
programmatically with some success. If there is only one embedded show, I
can delete it and save the document and all is well. If there are multiple
shows embedded (many different reviewers made changes) that is not the case.

In my test file, I have 3 embedded PPT shows because of 3 different
reviewers. I call EndReview, I loop through the shapes, delete the shapes
that are the PPT shows and then save. All the while I am watching the
shapes tree in the watch window.......when I save, 2 of the 3 deleted shapes
come back!!! I tried SaveAs with the same results. Any clues as to why
this is happening??

Thanks,
David
 
B

Bill Dilworth

Hi David,

Sorry you are having difficulty. Generally, with coding questions, it helps
to have the relative excerpt from the code.

Without the code I'll have to make some very large guesses. It may be a
looping error where the objects numeration is being moved as a result of a
prior one being deleted. This sounds reasonable, anyway.

If this doesn't point you in the direction of a solution, could you post
back with the section of the code? Also, include the versions of PowerPoint
this will be run from.

Thanks,

Bill Dilworth
Microsoft PPT MVP Team
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
D

David C. Johnson

Bill,
Thanks for the reply. The object numeration scenario you spoke about was
thought of. I loop through the list a few times to make sure I delete all
of them. I am keeping the watch window open and when I am stepping through
the code, I see each and every PPT embedded object deleted one by one. Then
when the Save or SaveAs call goes out, two of the three embedded PPT shows
reappears in the list. At any rate, here is my code. Don't laugh.....I am
not a VB/Office programmer. :)

I've tried everything I can throw at it. One solution that does seem to
work is to delete all the embedded PPT, saveas the file, then open the
saveas file and repeat until there are none left. The only problem with
that is that many copies of the file get created needlessly.

I am using VB 6.0 and PPT 2002.

Thanks
David

--------------------------------------------------------------
Dim ppPres As PowerPoint.Presentation
Dim slideMaster As Master
Dim ppSlide As Slide
Dim ppShape As PowerPoint.Shape
Dim pMasterShape As PowerPoint.Shape
Set ppPres = ppApp.Presentations.Open(Text1.Text, msoFalse)

If ppPres Is Nothing Then
GoTo NoPPT
End If
Set slideMaster = ppPres.slideMaster
ppPres.EndReview
If slideMaster Is Nothing Then
GoTo NoMaster
End If

ppPres.EndReview

'check to see if embedded PPT exist on the Master slide
bHaveEmbeddedPPT = False
For Each pMasterShape In slideMaster.Shapes
If pMasterShape.Type = msoEmbeddedOLEObject Then
If pMasterShape.OLEFormat.ProgId = "PowerPoint.Show.8" Then
bHaveRevisions = True
End If
End If
Next

While bHaveEmbeddedPPT = True
cnt = 0
'count how many embedded PPT's we have
For Each pMasterShape In slideMaster.Shapes
If pMasterShape.Type = msoEmbeddedOLEObject Then
If pMasterShape.OLEFormat.ProgId = "PowerPoint.Show.8" Then
cnt = cnt + 1
End If
End If
Next
If cnt = 0 Then
bHaveEmbeddedPPT = False
End If

'loop through and delete as many as we can
'If n is deleted, n+1 is reshuffled in the list becoming n (or is
it?)
'at any rate, this was the quickest way to do this for test purposes
'we'll recount and go through again until we delete all
For i = 1 To cnt
For Each pMasterShape In slideMaster.Shapes
If pMasterShape.Type = msoEmbeddedOLEObject Then
If pMasterShape.OLEFormat.ProgId = "PowerPoint.Show.8"
Then
pMasterShape.Delete
End If
End If
Next
Next

Wend

ppPres.SaveAs Text2.Text
 
B

Bill Dilworth

Try replacing the last loop after the comment with this section of code:

For i = slideMaster.Shapes.Count To 1 Step -1
Set pMasterShape = slideMaster.Shapes(i)
If pMasterShape.Type = msoEmbeddedOLEObject Then
If pMasterShape.OLEFormat.ProgID <> "PowerPoint.Show.8" Then
pMasterShape.Delete
End If
Next i

See if this helps.

Bill D.
 
D

David C. Johnson

I just tried this block of code instead of the two loops I had:

The file I am working with contains 3 embedded PPT objects on the Master
slide. I know that they are objects 6,7 and 8.
slideMaster.Shapes.Item(8).Delete
slideMaster.Shapes.Item(7).Delete
slideMaster.Shapes.Item(6).Delete

ppPres.SaveAs Text2.Text

Same thing! It deletes all three.....they disappear from the list. Then
the SaveAs saves the file under a new name and 2 of the 3 reappear.
Hmmmmmmmmm


David
 
D

David C. Johnson

Will do.....
I'll report back in a few.

Casey


Bill Dilworth said:
Try replacing the last loop after the comment with this section of code:

For i = slideMaster.Shapes.Count To 1 Step -1
Set pMasterShape = slideMaster.Shapes(i)
If pMasterShape.Type = msoEmbeddedOLEObject Then
If pMasterShape.OLEFormat.ProgID <> "PowerPoint.Show.8" Then
pMasterShape.Delete
End If
Next i

See if this helps.

Bill D.
 
D

David C. Johnson

I tried the loop with a "=" replacing the "<>" in the 4th line. Same
thing.......

This is a file that I did not start on the reviewing cycle and it was never
sent to me for review. It is a file that is on a server here at work.
I am thinking that the EndReview method is failing for some reason when
called via automation. When I reopen the file, the End Review button is
still there. If I click on the EndReview button, it turns it off and all of
the embedded PPT shows are deleted and I then can save.



Casey
 
B

Bill Dilworth

LOL

sorry, <> should be =

I abbreviated a lot of the code to test it. Just for got to switch it back.
 
B

Bill Dilworth

You may be right, and are beyond me on this one. One of the other vba
people may be able to better advise you.

Interesting, thought. If you add the line .saveas line after the .delete
line within the loop, does it get rid of them all? (keeping the for ...next
....step -1 routine.)

Keep saving as the same filename, not a series.

Bill D.
 
D

David C. Johnson

Yeah it still does the same thing. I've tried everything under the sun with
this......
Thanks for your help Bill...
David C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top