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
Related
I want to add a clickable checkbox (one or more) to a PowerPoint presentation slide. I'm using MacOS and Microsoft Office 365.
I guess that it is possible to do using macros created with VBA, but I have no idea what code needs to be created for this.
I would be very grateful if you would share the necessary code or suggest me another relevant ways to create clickable checkboxes in pptx under the Mac.
Checkboxes, labels, textboxes etc are all ActiveX features, and since ActiveX isn't supported on the Mac version of Office or in MacOS generally, you can't do this the way you would in Windows versions of Office.
You might be able to fake it by adding drawn rectangles and assigning a Run Macro action setting to each of them.
This page on the PPT FAQ that I maintain explains how to write the macro.
Determine which shape was clicked
https://www.pptfaq.com/FAQ00141_Determine_which_shape_was_clicked.htm
TL;DR - here's some sample code. This runs on both Windows and Mac (where bugs in PPT's VBA model force it to be more complicated than it would be otherwise):
Sub DoSomethingTo(oSh as Shape)
Dim oSl as Slide
Dim oShTemp as Shape
' oSh.Parent returns a valid reference to the shape's host slide:
Set oSl = ActivePresentation.Slides(oSh.Parent.SlideIndex)
' and oSh.Name works:
MsgBox oSh.Name
' So we use those two bits to get a reference
' to the clicked shape like so
Set oShTemp = oSl.Shapes(oSh.Name)
With oShTemp
.TextFrame.TextRange.Text = oSh.Name
' and whatever else you want to do with the shape
End With
End Sub
I'm trying to build a macro which will update only the selected linked object within a PowerPoint, but I cannot figure out how to do it.
The first part below is what I've used to update all linked objects, but I am currently dealing with massive Excel files, and presentations with 200+ linked objects, so one-at-a-time updating is the only way to go unfortunately.
The second part is what I was hoping would work.
First part:
Dim sld As Slide
Dim sh As Shape
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
sh.LinkFormat.Update
End If
Next
Next
Second part:
With ActiveWindow.Selection
.LinkFormat.Update
EndWith
I'm pretty inexperienced with PPT VBA, so please bear with me. Is it possible to build something like this? (It's going to be part of a more complicated macro, so it ultimately will be more convenient than just Right Click + Update Link)
Give this a try:
Sub UpdateOLELink()
ActiveWindow.Selection.ShapeRange.LinkFormat.Update
End Sub
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.
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.
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