Select Shape on SlideMaster in PowerPoint 2007

663 Views Asked by At

I am working on a plugin for PowerPoint ,which interacts with it when PowerPoint in SlideMaster view.

Depends on content, I need to select Shapes on either SlideMaster or on CustomLayouts.

I have managed to Select them on CustomLayouts, but I did not manage to do that, when Shapes are located on SlideMaster.

I tried to use following approaches:

First approach

presentation.Designs[1].SlideMaster.Shapes[1].Select();

This approach works only when user manually selects a particular slide master. Otherwise i get the exception:

"Shape (unknown member) : Invalid request. To select a shape, its view must be active."

Second approach

presentation.Application.ActiveWindow.View.Slide = document.Designs[2].SlideMaster;

When I use this approach I get the following exception:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I did not find any ways to activate a SlideMaster to select shapes on it.

Are the any ways to do that?

Thank you in advance.

1

There are 1 best solutions below

7
On

To select anything in PowerPoint, you need to manage the window's view. This will allow you to select the first shape on the slide master by switching the view first:

For PowerPoint 2007:

CommandBars.ExecuteMso ("ViewSlideMasterView")
DoEvents
ActivePresentation.SlideMaster.CustomLayouts(1).Select
SendKeys ("{UP}")

The non-SendKeys method that should work but doesn't on 2007 (tested OK on PowerPoint 2016):

ActiveWindow.ViewType = ppViewMasterThumbnails
With ActiveWindow.View.Slide
  .Shapes(1).Select
End With

As an aside, do you actually need to select the object? Depending on what you're doing with it, you might not even need to select it and hence don't need to manage window views. For example, if you want to copy it or format it, you don't need to select it. If you want to group it with something else then you do need to select it first.