How to save options of a VSTO add-in in the currently open file?

若如初见. 提交于 2019-12-14 03:53:47

问题


I'm building a VSTO add-in for Powerpoint 2010 and the options the add-in sets apply to the currently open file instead of a per-user config. Can I save these options in the current file (I mean, add custom XML to the .PPTX file)? If so, how?

Thanks for your help.


回答1:


If your Options are not too complex, I would go for Document Custom Properties. The following question illustrates how to use Custom Properties with Excel, they are supported in PowerPoint as well so this should provide a good starting point!




回答2:


For very simple data, custom properties are ok (so long as you're aware that anyone who opens the file will be able to see, edit and delete them). And note that because PPT shares a common, too-small, allocation of data between links and document properties, adding too many of one can wipe out the other.

I'd use tags instead. Every shape, slide and presentation object can have a tags collection, containing one or more Name / Value pairs of strings.

These are invisible to the user and will not interfere with the hyperlinks in the presentation.

' To add a tag
With ActivePresentation
  .Tags.Add "MyTagName", "MyTagValue"
End With

' To use a tag
If ActivePresentation.Tags("MyTagName") = "MyTagValue" Then
   ' Do something or other
End If


来源:https://stackoverflow.com/questions/11334278/how-to-save-options-of-a-vsto-add-in-in-the-currently-open-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!