I have a PowerPoint presentation in which some slides contain multiple shapes for the user to click on.
I want to capture which shape is clicked. I am able to capture if shape has test on it using macro but what if it shape contains any image?
Every shape on a slide has a unique ID property that you can examine to determine which shape is selected.
Or you can add a tag to the shape beforehand:
ActiveWindow.Selection.ShapeRange(1).Tags.Add "MyName", "MyValue"
then
If ActiveWindow.Selection.ShapeRange(1).Tags("MyName") = "MyValue" Then
' Whatever
Related
you can use VBA to hide shapes: VBA PowerPoint Display and Hide Shapes
But can you hide shapes randomly on a slide (all but one specific)?
I donĀ“t know how to make a random on a
ActivePresentation.Slides("Slide1").Shapes("Rectangle 1").Visible = False
I aspect, that i can hide a random shape on the actual slide by click(the Shape must have to be a visible shape before, so that another start of the code does hide randomly the next visible shape and not the hidden shape again).
I hide the toolbar, however need, fill the color menu. Whether possible to create a shape as the button with color and fill the selection shape into range selection cell from mouse
I have plane provide 3 different colors by using shape as a button, example Blue, Red and Black and if I select B:1 or A23 and click one of three colors shape the select range will fill by the same color. ( When I select range cell B:1 then click Red Shape, the cell B:1 will fill with Rd Color.
I have a VSTO written in VB.NET and want to maximize a selected image to the background. Documents tell me to remove the old shape and add a new one with AddPicture, but I have a template that includes image shapes already there and AddPicture puts the image in one of those shapes already there.
To prevent images from landing in the wrong shape I really just want to replace the original image with the resized one.
This is what I have:
dim src as PowerPoint.Shape = PowerPoint.Selection.ShapeRange.Item(1)
src.Export(file1, PowerPoint.PpShapeFormat.ppShapeFormatPNG)
dim img as Image = BitMap.FromFile(file1)
Then some image magic, and then:
img.Save(file2, PowerPoint.PpShapeFormat.ppShapeFormatPNG)
Dim _S As PowerPoint.Slide = ppApp.ActiveWindow.View.Slide
Dim _P As PowerPoint.Shape = _S.Shapes.AddPicture2(file2, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, _W, _H)
But that puts the image in the wrong template-shape.
Is there a way to actually replace the image in a shape without adding a new shape?
You can't insert an image inside a shape, only (in some cases) inside a placeholder, and you've mentioned that you specifically don't want to do that.
You can use an image to fill a shape, but unless you don't mind the image getting distorted, the aspect ratios of the image and the shape must match.
Suggestion: before adding the new image/shape, iterate through all the shapes on the slide looking for placeholder shapes. If any placeholder shape is of a type that can contain images (Content, Picture and Clip Art placeholders), fill it with dummy content (a few characters of text for Content, any random picture for the other two). Add your image; since the "image-capable" placeholders are already filled, the image will be added as a new shape. Then delete each of the shapes you've added dummy content to. When you delete a placeholder that has content, the content gets deleted and leaves the original empty placeholder behind.
How can I change the shape selection on another slide programmatically?
For example:
My current selection is on the shape 5 (the shape with id = 5) of the slide 3. How can I switch the selection on the shape 6 (the shape with id = 6) of the slide 2 programmatically?
Note: I am writing code in C#, VS Ultimate 2013, PowerPoint 2013
In an X-Y scatter plot, I manually add text labels to data points via Point.DataLabel. Unfortunately I find that when points are crowded then it can be difficult to tell which series a label belongs to. Therefore I want to color my text labels to match the markers.
I am happy with the default markers and their colors, but unfortunately they contain MarkerForegroundColor = -1 and MarkerForegroundColorIndex = 0, no matter which series I look at. Furthermore, Application.ActivePresentation.ColorSchemes is empty. I note that point.MarkerStyle = xlMarkerStyleAutomatic.
I found that the colors correspond to the accent colors in the active Theme (only available in PowerPoint 2007 onwards):
presentation.SlideMaster.Theme.ThemeColorScheme.Colors(MsoThemeColorSchemeIndex.msoThemeAccent1 + series_i % 6);