VBA - Ungroup a Table in PowerPoint - vba

I am looking for an automated way to ungroup a table in power point to create shapes.
I found the following tutorial:
Tutorial
Further, I wanted to record the macro(I am quite new to vba), however in power point 2010 the macro recorder is not available any more. Any suggestions, how to create the above tutorial in vba?
I appreciate your replies!

Here's an example to get you started. Be sure to select the table you want to work with first.
Sub PasteAndUngroup()
Dim oSh As Shape
Dim oSl As Slide
Set oSh = ActiveWindow.Selection.ShapeRange(1)
Set oSl = oSh.Parent
oSh.Copy
Set oSh = oSl.Shapes.PasteSpecial(ppPasteEnhancedMetafile)(1)
oSh.Ungroup
End Sub

Related

How can I select all in Powerpoint VBA?

I have been struggling for a while to find a VBA code to select all the slides and all the shapes of a presentation (for some reason this seems to be of no one's interest). I have tried to set up a range with all the slides and then select all the shapes of the range, but that does not work. I also try looping slide by slide and accumulate the selection (msoFalse), but for that you also need to activate each slide and I was unable to do that.
I think selecting all the slides and shapes at once is useful to manipulate the fonts or run a full spell check. Your help would be really appreciated!!
Selecting objects in VBA is generally to be avoided. It's unreliable and slow. Instead, loop through every shape on every slide and perform whatever operation you need:
Sub DoStuffToShapes()
Dim oSlide as Slide
Dim oShape as Shape
For each oSlide in ActivePresentation.Slides
For each oShape in oSlide.Shapes
'Do stuff to the shape
Next oShape
Next oSlide
End Sub
If you've created a font theme and applied it to the Slide Master and Layouts, it's usually easier and faster to change fonts by modifying the theme and/or master rather than using VBA. VBA isn't needed for a spellcheck either.

Is it possible to update only a selected linked object in PPT?

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

Visio VBA : Connect a line shape to two other shapes

I am dropping shapes on my Page via VBA UserForms. Amongst others I need to drop a "curved line" shape which should connect two specified shapes.
I found out how to directly create a connection here but I want the shape from my specific master because it has some custom Data Properties.
I expected there to be some Fields in the DataSheet of the Connector-Shape where I could reference the start and end shapes? could not find anything more helpful.
Thanks for any hints!
Solution from here
Dim shp As Visio.Shape 'connector
Dim src As Visio.Shape 'connect this
Dim aim As Visio.Shape 'to this
[...] 'Set shape variables
shp.Cells("BeginX").GlueTo src.Cells("PinX")
shp.Cells("EndX").GlueTo aim.Cells("PinX")

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

Need to set shape position in PowerPoint to the same value across all slides

I have dozens of PowerPoint shows that contain dozens of slides each. They are very basic in that there is only one shape on each slide and there is no animation being used on the shape or between slides. The issue is that the person who created them didn't really pay attention to the vertical position of the shapes from slide to slide so it's very noticeable when going from one slide to the next.
I would like to be able to quickly set the vertical position to the same value for each shape on each slide. The horizontal position is fine. I've been doing them manually but there are a lot of slides and slide shows to go through and I'd rather not have to do this as it is very time consuming.
I've done some searching here on this site as well as on Google but haven't found anything yet. If it requires VBA code, that's fine too.
I am using PowerPoint 2010.
As a starting point (total air code, mind you):
Sub LineEmUpDano()
Dim oSl as Slide
Dim sngTop as Single
' Pick up the top position of the first shape
' on the first slide:
SngTop = ActivePresentation.Slides(1).Shapes(1).Top
' Apply the top position to each slide in the pres
For Each oSl in ActivePresentation.Slides
oSl.Shapes(1).Top = sngTop
' you could instead use
' oSl.Shapes(1).Top = 42 ' or whatever value you like
' Values are in points, 72 points to the inch
Next ' slide
End Sub
Using Steve's suggestion above as a jumping off point and then reading some tutorials I was able to come up with a working script:
Sub UniformHeight()
Dim SlideToCheck As Slide
Dim ShapeIndex As Integer
For Each SlideToCheck In ActivePresentation.Slides
For ShapeIndex = SlideToCheck.Shapes.Count To 1 Step -1
SlideToCheck.Shapes(ShapeIndex).Top = 36
Next
Next
End Sub