(JavaScript API 1.3 for Office) Custom Properties add method

半腔热情 提交于 2019-12-20 07:13:48

问题


Here's a link tho what made me start digging into custom Props again.

I can see that my customProperties are 0 so i assume getCount is somewhat working, even though I'm accessing it through items.length and not customProps.getCount()

Is this still intended or am i just not doing it right and it's possible doing as in the MS Office Documentation

Now the main part of my question, the add method. Whatever i try it crashes and i get an exception. Can i assume add method is still not properly implemented?

This is all on Word API.

Any help would be appreciated. Thank you very much!


回答1:


I verified this code does not crash Word and works. (assuming you are in latest builds, if your items.count works, this should too.

 Word.run(function (context) {
  context.document.properties.customProperties.add("PropertyName", 1234);
  return context.sync();
  }) 

If this does not work, please reply with your build number. thx.




回答2:


Thank you all, I was on my laptop and still needed an update. Newbie mistake. I've tested that code and it works.



来源:https://stackoverflow.com/questions/42304942/javascript-api-1-3-for-office-custom-properties-add-method

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