Reputation: 21
in my Power Point add-in I am loading .svg file within slide using this code
Slide activeSlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;
PowerPoint.Shape ppPicture = activeSlide.Shapes.AddPicture(testImageUrl, MsoTriState.msoTrue, MsoTriState.msoTrue, 0, 0);
ppPicture.LinkFormat.SourceFullName = testImageUrl;
then I need to ungroup this file, like it happens when clicking mouse right button and selecting menu point "Convert to Shape".
ppPicture.Ungroup();
throws System.UnauthorizedAccessException: 'This member can only be accessed for a group.'
So how can I do it ?
Upvotes: 2
Views: 303
Reputation: 1
I know this is 4 years old, but in case anyone stumbles upon this, the way to do it is:
shape.Select
CommandBars.ExecuteMso ("SVGEdit")
You can then ungroup everything and edit each individual shape.
Hope this helps.
Upvotes: 0
Reputation: 31
Sorry but can you provide more information? For example what is testImageUrl
and bc Shape.LinkFormat
is a way to manage OLE object, object linking and embedding, so it would typically be Excel > Powerpoint or Excel > Word if we think of how a normal application would work.
Please note, the SourceFullName
property takes on different properties depending if its a table or chart:
table = {file.fullname}!{range.address} or chart = {file.fullname}![{file.name}]{worksheet.name}{chart.name}
It is possible that the file is located on a public server (e.g., OneDrive, SharePoint, Teams, etc.) which in that case it would have a "URL" in the filename but the logic remains the same.
More information would be helpful to understand what you are trying to accomplish. Alternatively, if the object is already in the clipboard you can utilize
var shape = slide.Shapes.PasteSpecial(DataType: PpPasteDataType.ppPasteOLEObject, Link: Microsoft.Office.Core.MsoTriState.msoTrue)[1];
Which would paste and automatically select the shape for you to then try and perform shape.Ungroup()
.
Upvotes: 0