PDA

View Full Version : Power Point Generation with Excel



monzat
10-28-2013, 01:08 AM
Hello,i'm currently trying to create with VBA an automation of my ppt. I copied paste with link from Excel to Ppt the informations i needed.What i'm trying to do is to make the ppt poping up when the user click on the commandbutton. This is something i suceed to do.But i fell like the information doesn't automaticly update and furthermore i don't succeed to delete the links.Can you help me? Private Sub CommandButton1_Click() Sheets("Feuil2").Visible = True' Application.Goto Reference:="Nomsauv" Nomsauv = Selection.Offset(0, 0).Value 'Opening Ppt Document Set appPowerPointApplication = New PowerPoint.Application bPowerPointisOpened = True appPowerPointApplication.Visible = True appPowerPointApplication.Presentations.Open Filename:=ThisWorkbook.Path & "\XX.ppt", ReadOnly:=True bPowerPointPresentationsIsOpened = True Dim oSlide As Slide Dim oShape As Shape For Each oSlide In appPowerPointApplication.Slides For Each oShape In oSlide.Shapes If oShape.Type >= 7 And oShape.Type

monzat
10-28-2013, 01:14 AM
Hello,i'm currently trying to create with VBA an automation of my ppt. I copied paste with link from Excel to Ppt the informations i needed.What i'm trying to do is to make the ppt poping up when the user click on the commandbutton. This is something i suceed to do.But i fell like the information doesn't automaticly update and furthermore i don't succeed to delete the links.Can you help me? Private Sub CommandButton1_Click() Sheets("Feuil2").Visible = True' Application.Goto Reference:="Nomsauv" Nomsauv = Selection.Offset(0, 0).Value 'Opening Ppt Document Set appPowerPointApplication = New PowerPoint.Application bPowerPointisOpened = True appPowerPointApplication.Visible = True appPowerPointApplication.Presentations.Open Filename:=ThisWorkbook.Path & "\XX.ppt", ReadOnly:=True bPowerPointPresentationsIsOpened = True Dim oSlide As Slide Dim oShape As Shape For Each oSlide In appPowerPointApplication.Slides For Each oShape In oSlide.Shapes If oShape.Type >= 7 And oShape.TypeoShape.LinkFormat.BreakLinkEnd IfNext oShapeNext oSlide Sheets("Feuil2").Visible = False End Sub

p45cal
10-28-2013, 06:32 AM
For others, also posted a few days ago at http://www.mrexcel.com/forum/excel-questions/679962-code-works-next-10-rows-msolinkedoleobject-going-new-ppt-slide-but-how-do-i-include-header-row-range.html

for monzat/florrian
some light reading: http://www.excelguru.ca/content.php?184

Try:

Private Sub CommandButton1_Click()
Sheets("Feuil2").Visible = True
' Application.Goto Reference:="Nomsauv"
Nomsauv = Selection.Offset(0, 0).Value
'Opening Ppt Document
Set appPowerPointApplication = New PowerPoint.Application
bPowerPointisOpened = True
appPowerPointApplication.Visible = True
Set myPPT = appPowerPointApplication.Presentations.Open(Filename:=ThisWorkbook.Path & "\XX.ppt", ReadOnly:=True)
bPowerPointPresentationsIsOpened = True
Dim oSlide As Slide
Dim oShape ' As Shape
For Each oSlide In myPPT.Slides
For Each oShape In oSlide.Shapes
If oShape.Type >= 7 And oShape.Type <= 12 Then
oShape.LinkFormat.BreakLink
End If
Next oShape
Next oSlide
Sheets("Feuil2").Visible = False
End Sub
but note that you've opened the presentation as read-only so you can only save it under another name.

monzat
10-28-2013, 02:33 PM
Thanks for your answer.

Unfortunatly i can't open your link.

Concerning the read only i'll a Line of code to rename the file.

Regards.

p45cal
10-28-2013, 05:25 PM
Thanks for your answer.

Unfortunatly i can't open your link.You're right, neither can I!. The site must be down for a while. Here's another similar link:
http://www.excelfox.com/forum/f25/message-to-cross-posters-1172/
It's not needed for the answer to your problem. Did the code work?

monzat
10-30-2013, 12:04 AM
Hello,sorry for the delay. Actually i tried what you wrote.But it sill says "Type Incompatibiliy" Error Nb 13.Maybe the code to delete the links is not the right, i saw many different codes to do that.Thanks for your help!!!!

p45cal
10-30-2013, 05:21 AM
1. If you click Debug when you get the error, which line of the code is highlighted in yellow?
2. What version of Excel are you using?
3. What version of PowerPoint are you using?

monzat
10-30-2013, 06:31 AM
What is strange is that i don't have the possibility to debug. It seems that the code executes until the end, the ppt opens but an error message appears after it's been executed.But i'm sure that the issue is on the Breaklink part.I'm using 2003 version of both.Thanks for your help.

p45cal
10-30-2013, 08:54 AM
The BreakLink method wasn't introduced until Office 2007.
I don't have a solution for you.
Perhaps if the copy/paste is done in vba (or manually, for that matter) you do not paste link in the first place.

p45cal
10-30-2013, 08:57 AM
The BreakLink method wasn't introduced until Office 2007.
I don't have a solution for you.
Perhaps if the copy/paste is done in vba (or manually, for that matter) you do not paste link in the first place.

Compicated, but this might help:
http://www.vbaexpress.com/forum/showthread.php?15223-Save-an-unlinked-version
or similar:
http://www.vbaexpress.com/forum/showthread.php?30356-Break-Links-Code-Help
and different:
http://www.vbaexpress.com/forum/showthread.php?24287-Break-image-links

ps I notice that your code is uncannily similar to the code here:
http://www.xtremevbtalk.com/showthread.php?t=315898
where there is the comment:
"Oops. I just discovered a much simpler approach for 2007 from an old post (this didn't work for 2003)."

monzat
10-30-2013, 09:11 AM
Thanks i'll have a look.In an other file i found for a word versionappWordApplication.ActiveDocument.Fields.UnlinkDo you know the function unlink? Can it work with ppt?

p45cal
10-30-2013, 10:43 AM
Thanks i'll have a look.In an other file i found for a word versionappWordApplication.ActiveDocument.Fields.UnlinkDo you know the function unlink? Can it work with ppt?No.