How to copy template into slide from another PowerPoint? - vba

I need to use a template that's used in a separate PowerPoint on a PowerPoint that's made using vba (I'll refer to the one vba makes as "this:).
The way I was doing it was getting the custom layout from the slide master in the template PowerPoint and setting it equal to this PowerPoint custom layout.
What was happening was that it looked like this PowerPoint was completely relying on the template in the template PowerPoint ( I guess it was a direct reference). When I closed that one it also closed this PowerPoint. How do I copy a template (custom layout) into another PowerPoint so it's not a direct reference and relying on template slide to constantly be open

You can copy a slide master (and all its associated layouts) you like from one presentation into another.
Copy the slide master from the first presentation
Open both presentations: the one you want to copy a slide master from, and the one you want to paste the slide master into.
In the presentation that has the slide master, you want to copy, on the View tab, select Slide Master.
In the slide thumbnail pane, right-click the slide master, and then select Copy.
Paste the slide master into the new presentation
On the View tab, select Switch Windows, and then select the presentation that you want to paste the slide master to.
On the View tab, select Slide Master.
In the thumbnail pane, right-click the slide master, and then do one of the following;
3.1. To take on the theme colours, fonts, and effects of the destination presentation that you are pasting to, click Use Destination Theme.
3.2. To maintain the theme colours, fonts, and effects of the presentation that you are copying from, click Keep Source Formatting.
When you're finished, select Close Master View.
--
Follow the instructions with pictures given here.

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 Interop API access multiple slide masters inside slide master view

I have powerpoint presentation with multiple master slides.I want to access current active powerpoint presentation slide master in master view using InterOp API and VB.net. When I tried to access active slide master it always select the first slide master instead of active master slide.I tried it with slides and I could access current slide.But in slideMaster view I couldn't find way to access specified slide master.
If(ActiveWindow.ActivePane.ViewType = PowerPoint.PpViewType.ppViewSlideMaster) Then 'condition
ActivePresentation.Slides(2) 'this way I can access specified slide.
ActivePresentation.SlideMaster
If by "active slide master" you mean the slide master used by the currently selected slide you can access it via
ActiveWindow.Selection.SlideRange(1).Design.SlideMaster
Or likewise for the master of the first slide in the presentation
ActivePresentation.Slides(1).Design.SlideMaster
Or in slide master view
If ActiveWindow.ActivePane.ViewType = ppViewMasterThumbnails Or _
ActiveWindow.ActivePane.ViewType = ppViewSlideMaster Then
ActiveWindow.View.Slide...
End If
Debug.Print ActiveWindow.View.Slide.Name
Debug.Print ActiveWindow.View.Slide.Design.Name
In Slide Master view, PPT 2010 (and probably 2007 too), the first line gives you the name of the currently selected Layout or Master, the second gives you the name of the Design that underlies the master.
In a multi-master presentation, you look at the Designs collection to arrive at the masters.
Other versions of PPT work differently. This explains more about designs, layouts, masters, lions, tigers and bears, o my:
Slides, Masters, Designs, Layouts ... how do they all fit together?

maintaining image object visibility with vba

i am developing a large non-linear powerpoint which has many sub sections to it. This has necessitated a table of contents slide (TOC). in this slide i am representing each section with its own picture. also on the slide are 2 buttons which let the user switch between images. The buttons do this by setting the appropriate section image to visible and all the others to invisible, so that only one sections image is visible at a time. my goal is to make sure that whenever the user goes back to the table of contents slide that the slide displays the same section image each time, regardless of which section what entered the previous time, i.e. the image for section 1 should be visible whenever the user goes back to the table of contents. how do i go about doing this?
also, if i can find new sources to learn more about syntax and other vba coding, i would be most appreciative.
i already consult:
pptalchemy.co.uk
skp.mvps.org
msdn.microsoft.com
i just cannot find more good sites that will help.
I don't quite understand the situation, but one possibility:
Add another slide before the TOC. You could make it a duplicate of the TOC slide (with the image you want in place).
Instead of linking back to the "real" TOC slide, link to this one instead.
On this slide, add a rectangle that covers the entire slide, make it 99% transparent and give it a Run Macro mouse over action setting.
Have the macro do nothing more than set the image you want on slide 2 to be visible, then jump to slide 2 (the real TOC slide), eg
SlideShowWindows(1).View.GoToSlide(2)
The mouse over macro will trigger as soon as the user moves the mouse, and since that will trigger a jump from one slide to an identical one, it will be invisible to the user.
most of the solution came from [pptalchemy] (http://www.pptalchemy.co.uk/PowerPoint_Auto_Open_Code.html):
I downloaded the custom ui editor for microsoft office
I added the code from ppt alchemy to the custom ui editor for the slide show.
In vba i added the code:
Sub onloadcode()
Debug.Print "Running"
End Sub
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = SSW.Presentation.Slides("TOC").SlideIndex Then
'code here'
end if
end sub
the code executes perfectly now, and i have condensed my table of contents from 9 slides down to 1. Just, don't add features to the code until you have everything in place to accept them. In my case i added the code for text boxes which did not exist yet and that messed up my code a lot. Once i made all of the objects for the code and then added the code it worked perfectly.