How to display "Links" / "Update Links" dialog in PowerPoint with VBA? - vba

In Excel, this should be done easily (although form me it doesn't work for some reason):
ThisWorkbook.Parent.Dialogs(xlDialogOpenLinks).Show
or simply
Application.Dialogs(xlDialogOpenLinks).Show
But how can I accomplish that under PowerPoint?
The PowerPoint.Application.Dialogs property does not exist and cannot be called at runtime...

You could loop through the slide and slide shapes, testing if the shape is a linked object or a linked picture etc. and listing out the LinkFormat.SourceFullName.
You could then amend the LinkFormat.SourceFullName.
See example here:
Edit links in Powerpoint VBA

Related

VBA for Powerpoint: Change Slide in One Powerpoint by Selecting Button in Another

I am a beginner at VBA.
I am designing a somewhat interactive Powerpoint presentation/s. I want to be able to have three separate Powerpoint presentations open that will link together. I have been trying (without success) to create, in VBA, code which will change the current displayed slide on one Powerpoint file by clicking a button in another. I can hyperlink to the set slide but this causes this slide to pop up on the same screen in which it is clicked, despite it being already open in another screen (I don't want this).
Thanks in advance for any help,
Holly
VBA uses an object model that is a huge hierarchy of attributes and functions that represent the application. You can use this model to view and update attributes to get text, resize, and modify the application. You should look at some tutorials to get you started. When editing your code, you can press F2 to see and explore this object model. You can press F8 to run your code line by line (debug mode) and see what is happening.
To your question, you can access the open presentations in the application.presentations object (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentations). You could then use a presentation in that list and use the ActiveWindow.View.goToSlide function (https://learn.microsoft.com/en-us/office/vba/api/powerpoint.view.gotoslide). Here is a free tutorial that I've used in my VBA journey (https://www.tutorialspoint.com/vba/index.htm).
PowerPoint has a Presentations collection that contains all currently open presentations. You can get a reference to any of them via Presentations("name") where "name" is the filename of the presentation, sans extension.
So ... assuming you've got three presentations open, a.pptx, b.pptx, c.pptx you can do something like this:
Sub SlideChange()
With Presentations("c")
.SlideShowWindow.View.GotoSlide (3)
End With
End Sub
If you run the above in any of the presentations, it will change the slide show window displaying presentation c to the third slide.

Embed a linked copy of a slide from other Powerpoint presentation in another Powerpoint presentation

The problem is this:
I´ve got two Powerpoint presentations.
I want to link the second slide of one presentation into the another presentation.
How I do this?
I can embed a presentation into another but I want to select the second slide, anyone can help?
You must have two powerpoint files opened.
In the source powerpoint:
Click on the slide preview and copy.
In the target powerpoint:
Create a new slide and then select the home ribbon.
Below paste there are more options, click on paste Special and then Paste Link.
One option must appear: 'Microsoft Powerpoint Slide Object'
Resize the object to fill the entire slide and it´s done.

How to use VBA in PowerPoint to open an embedded OLE object

I think this is a simple question, but I have spent days searching for an answer and nothing yet.
I have an OLE object embedded into a PowerPoint presentation (created using PPT 2010). I embedded it (a pdf file) through the insert>object>create from file>display as icon method, so that it displays as a little icon on a slide.
My goal is to open it on click of a shape, where the shape is on a different slide from the slide the pdf is on. The pdf is on slide 5, the trigger shape is on slide 6. The goal is to open it during slideshow viewing (and it must be done through VBA instead of animations for other reasons).
I thought the following would work:
Sub OpenMyDoc()
ActivePresentation.Slides(5).Shapes("My Doc").OLEFormat.DoVerb(1)
End Sub
I had assigned that macro as an on click "action" through the insert>links method.
I have also tried the following variations, with no luck (nothing happens at all when I click on the triggering shape):
ActivePresentation.SlideShowWindow.View.Slide.Shapes("My Doc").OLEFormat.DoVerb(1)
I also tried:
With SlideShowWindows(1).Presentation.Slides(5).Shapes("My Doc")
OLEFormat.DoVerb(1)
End With
I also tried:
ActivePresentation.Slides.Item(5).Shapes.Item("My Doc").OLEFormat.DoVerb(1)
Other macros (mostly message boxes) in the presentation, and on the same slide work, so I'm sure it's not a permissions or other setting issue.
I am using master slides, but can't seem to trace the problem to that.
You probably saw an error message when you ran your code; the error message explains the problem, though in somewhat Microsoftcryptic fashion. You can only activate OLE objects from Slide or Notes view.
Instead, you can do this:
ActivePresentation.Slides(1).Shapes(4).ActionSettings(1).Hyperlink.Follow
where Shapes(4) is hyperlinked to the PDF you want to launch.
[EDIT]
But since hyperlinking isn't an option, and since you have to be in slide view to activate the embedded object, this works here:
' Activate the presentation window
' You might need to make sure it's in normal view
ActivePresentation.Windows(1).Activate
' Launch the OLE object:
ActivePresentation.Slides(1).Shapes(1).OLEFormat.DoVerb (1)
' And immediately switch back to slide show view
SlideShowWindows(1).Activate

Powerpoint 2007 - Inserting dynamic data

so I've found that Powerpoint 2007 has no bookmark functionality. So I can't just insert dynamic data into a presentation. Also, there are no autostart event handler, but I found a way of doing it by editing the XML data. This now works, I've got a custom event handler that is run as expected.
Now, I tried to solve the no bookmark functionality by adding a label insted. Since a label has a name I can assign the Caption property a value. And that value can be dynamic data.
And this actually works, yay! BUT, this presentation has a custom font and font embedding is crucial. And now I've found that PowerPoint 2007 doesn't look to support font embedding on labels. And probably not buttons and textboxes as well. That is, the typical visual studio controls.
Are there any other ways of fixing this? A normal text placeholder doesn't have an ID.
But can I target them anyway? It's just some text in the footer of a slide design that I'm trying to put dynamic data.
Ok, so I found out how to target textboxes in PowerPoint 2007.
ActivePresentation.SlideMaster.CustomLayouts.Item(11).Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=25).Select
ActiveWindow.Selection.TextRange.Text = "New text that should be inserted"
The problem now is how to run this automatically. New thread for that.

VBA PowerPoint Online Guide and How to Record a Macro

Could anyone recommend to me a good online guide to PowerPoint VBA? Also, does anyone has advice on how to record a macro in PowerPoint?
Microsoft remove macro recorder from PowerPoint 2007.
To view the struct of objects use Watch (Shift +F9) in object.
For Example
dim ppt as powerpoint.Presentation
set ppt =activepresentation
add watch to ppt to view the struct of object Presentation
otherwise
Add a new class module
in the class declare
Private WithEvents ppt As PowerPoint.Application
in comon module declare one instance from classCreate(default is Class1) using
set x= new class1
Now in module class you can get events for you presentation (in left combo up the code window)
Bruno Leite
Office Developer
To record a powerpoint macro:
In the menu bar, click on Tools
Mouse over Macro > and the submenu will be displayed
Click the Record button - a new toolbar will be displayed
Do your thing
Click the stop button on the new macro toolbar
Click on Tools->Macro->Macros. Find the macro you just recorded and click the Edit button. That will show you what was recorded. Make your modifications and click the triangular run button (or push F5) to run your code.
As far as an online guide, I usually think of a question and use Google or ask a question here on StackOverflow.com. I've been able to answer most of my questions that way, I haven't found a particular main resource for all things Powerpoint VBA.
Also, you can find answers that can help you by looking into VBA articles for other MS Office products - a lot of things that are not Powerpoint-specific (general VBA) will be the same as for the other products.