Updating Powerpoint embedded in excel using vba - vba

I have a excel file in which 3 Powerpoint presentations are embedded(as object). These are the blank templates of the deck I want to prepare. How can I assign these embedded Powerpoint presentations through VBA. I know that I can keep Powerpoint presentations separately and access them but I want to make them into one file this time. Thanks in advance

OK, assuming you have a PPT presentation embedded in Excel and its name is "Object 1"
Dim oSh As Shape
Set oSh = ActiveSheet.Shapes("Object 1")
With oSh
' Uncomment the appropriate line for the result you want
' Show
'.OLEFormat.Verb (1)
' Edit (in place)
'.OLEFormat.Verb (2)
' Open
.OLEFormat.Verb (3)
End With

Related

VBA Powerpoint : what is the VBA equivalent to "hyperlink to a different Powerpoint Presentation?

I want to use several slideshows (in kiosk mode if possible), to be able to jump between them, without going back in edit mode...
No problem to do it with shapes and "hyperlink to a different powerpoint presentation".
But i'd need to do it also in VBA macros, in some slides.
For example, after a quiz is finished, jump to another slideshowwindow and a given slide, and give focus to that slideshowwindow :
What would be the code like ?
I'm unable to give focus to the new slideshowwindow...
I suppose it is the equivalent of what "hyperlink to a different PPT Presentation does, but i can't figure to do it.
Thank you very much in advance !
Alex
This Code opens a Presentation goes to Slide Number 5 and starts in Kiosk Mode
Dim PowerPointApp As PowerPoint.Application
Dim myPPT As PowerPoint.Presentation
'Open the Slideshow
Set myPPT = PowerPointApp.Presentations.Open(FileName:="filename.pptx")
Application.ActivePresentation.SlideShowSettings.ShowType = ppShowTypeKiosk
'You need this to work
ActivePresentation.SlideShowWindow.View.Exit
ActivePresentation.SlideShowSettings.Run
'Goto Slide number 5
myPPT.Windows(1).View.GotoSlide 5
'Start Slide Show
myPPT.SlideShowSettings.Run

Powerpoint VBA: Open Source of Linked Excel Chart

I have a PowerPoint presentation with several Excel charts pasted as links. Using VBA, I have checked, and the type of these shapes is msoLinkedOLEObject.
Knowing this, I would like to first open the Excel file that contains the original chart through VBA and then use the "update link" command of the chart, like this:
I wish to open the workbooks first because using the "update link" command with an open Excel file is usually faster for me than just using the "update link" command directly (maybe because some PowerPoint presentations and some workbooks are really extense).
For the sld.Shapes(i).LinkFormat part of the code, I can use .UpdateLinks to directly refresh the data, but I cannot find any way to directly open the Excel source file (in the same way I can by manually clicking the linked chart).
Could this be achieved?
Sub UpdateExcelLinkedCharts()
Dim pres As Presentation
Dim sld As Slide
Dim shp As Shape
Set pres = Application.ActivePresentation
'Loop through all active slides in the presentation
For Each sld In pres.Slides
If sld.SlideShowTransition.Hidden = msoFalse Then
'If the slide is a msoLinkedOLEObject, proceed to update its link
For i = 1 To sld.Shapes.Count
If sld.Shapes(i).Type = 10 Then
sld.Shapes(i).LinkFormat.UpdateLinks
End If
Next i
End If
Next sld
MsgBox ("All Links Updated!")
End Sub
You can either use
sld.Shapes(i).OLEFormat.Activate
Or
sld.Shapes(i).OLEFormat.DoVerb
followed by sld.Shapes(i).LinkFormat.Update
Both will open the linked object so you can edit it. But notice that this is not enough to have a reference to an Excel Object that you can manipulate through VBA.

VBA code to auto update PowerPoint links to Word

I have hundreds of PowerPoint presentations that all have linked Word objects in them. How can I auto-update all of the links without opening each presentation? I'm assuming it'll be done with VBA, but the only VBA examples I can find are for auto-updating linked Excel objects. I'm not familiar enough with VBA to modify the code.
Ultimately, I'd like to run this via Command Prompt.
Using PowerPoint & Word 2013.
DragonSamu's right ... but to get you started, try this from within PPT itself, then work out how to rewrite it in a scripting language or something that will compile to an EXE
For each file you want to process, open the file (via code) then
Call UpdateLinks(ActivePresentation)
Sub UpdateLinks(oPres As Presentation)
Dim oSl As Slide
Dim oSh As Shape
For Each oSl In oPres.Slides
For Each oSh In oSl.Shapes
If oSh.Type = msoLinkedOLEObject Then
oSh.LinkFormat.Update
End If
Next
Next
End Sub

PowerPoint Text to Speech Macro

I want to be able to create a macro that will start text-to-speech on the text that is in the presenters notes. I will be applying the macro to a ActiveX button that will allow the user to start the reading and eventaully I would like to time the animations of the slides to the speech.
I have sucess in Excel VBA in being able to write out the command to speak a cell with:
application.speech.speak (sheet1.cells(1,1))
and I found a code that will enter text into the speaker notes section for all slides.
Sub AddTextAllSpeakerNotes()
Dim sld As Slide
For Each sld In ActivePresentation.Slides
sld.NotesPage.Shapes.Placeholders(2).TextFrame.TextRange = ""
Next sld
End Sub
I have added the Microsoft Speech Object Library reference, but I can never get the VBA to recognize the speech commands and auto-complete any commands that will help me figure out how to get any further.
How can I write a code that will apply the text-to-speech command to the speaker notes section of a particular slide.
As commented, you can try this:
Dim XL As Excel.Application
Set XL = New Excel.Application
XL.Speech.Speak "I was able to make power point speak"
Provided you added reference to:
Microsoft Excel XX.X Object Library
Once you've bound Excel to PowerPoint, you can directly use its methods from there. In above code, you can simply replace the argument with the actual PPT object that contains the string you want spoken. HTH.

How to edit / ungroup EMF pastes in PPT using VBA?

it's Martin from Berlin (Germany - so please excuse my wrong English)...
I'm trying to edit EMF pastes in PPT using VBA. The EMF pastes are Excel charts and I used
ActiveWindow.Selection.SlideRange.Shapes.PasteSpecial DataType:=3 (enhanced metafile)
Without VBA it is easy: Just rightclick the image and "ungroup" (2x).
In VBA I tried the following:
1. Selecting the right shape (works), then
ActiveWindow.Selection.ShapeRange.Ungroup.Select
This runs on an error: "...cannot ungroup".
In another thread a "solution" was given: Recording a macro -> not possible in PPT 2007!
When I record a macro in PPT 2003, it says exactly the same:
ActiveWindow.Selection.ShapeRange.Ungroup.Select
but it doesn't work.
It seems that there should be one step before that converts the emf image into "office format" (if you do it without VBA after clicking "ungroup" a message box occurs that askes, if you want to convert the graphics into "office format").
Any idea what to do that ungroup is working with VBA?
This works here:
Sub UngroupPastedChart()
Dim oShRange As ShapeRange
Dim oSh As Shape
Set oShRange = ActiveWindow.Selection.SlideRange.Shapes.PasteSpecial(ppPasteEnhancedMetafile)
Set oShRange = oShRange.Ungroup
Set oShRange = oShRange.Ungroup
End Sub
and add oShRange.Select if you want the ungrouped shapes to be selected at the end.