Reputation: 21
I am writing a VSTO PowerPoint add-in. One of the things I would like to achieve is to be able to update custom properties programmatically using C#.
If I link a custom property to a text box (using GUI), I am able to display the value of the property in a slide - see the two images below.
If I want to change other existing properties that are not linked, it works as expected using this code:
doc.CustomDocumentProperties[propName].Value = propValue;
However, for linked properties the value is not changed. In Excel, I have been able to change the value by following the link set in the property
DocumentProperty property = doc.CustomDocumentProperties[propName];
if (property != null && property.LinkToContent && property.LinkSource != null)
{
workbook.Names.Item(property.LinkSource).RefersToRange.Value = propValue;
}
However, I am unable to find something like this in PowerPoint.
Alternatively, I was wondering if i could solve this by deleting the custom property and then recreating it with the new value. But I can't seem to find a method to delete custom property either.
Upvotes: 2
Views: 1248
Reputation: 25663
You might find this discussion useful: https://answers.microsoft.com/en-us/office/forum/office_2007-powerpoint/powerpoint-equivalent-of-word-bookmarks/0ff65d38-1980-4faa-83c4-f434b07d5b61?db=5&auth=1 Steve Rindsberg is one of the leading authorities on PowerPoint...
As far as I know (based on that discussion and my own testing), there's no programmatic way to create linked content in a PowerPoint presentation.
And it's not possible to change the content displayed on a slide via changing the value of a linked custom document property.
That discussion recommends working with the Tag
property of Shapes, Slides and Paragraphs in order to identify something for editing via automation.
It's a shame, really, that PowerPoint doesn't have the "content controls" functionality that Word has, where it's possible to link a content control to a node in a Custom XML Part - change the value in one and it's reflected in the other.
Upvotes: 1