简体   繁体   English

C#单词互操作中的VBA“style().LinkToListTemplate ListTemplate := Nothing”

[英]VBA “style().LinkToListTemplate ListTemplate := Nothing” in c# word interop

There is a word VBA method "style("style").LinkToListTemplate ListTemplate:=Nothing" which is used to set the style numbering to None.有一个词 VBA 方法 "style("style").LinkToListTemplate ListTemplate:=Nothing" 用于将样式编号设置为无。 My problem is that I cannot find the same in C# word interop.我的问题是我在 C# word interop 中找不到相同的内容。 The method exists but does not work with style.LinkToListTemplate(null).该方法存在但不适用于 style.LinkToListTemplate(null)。

The LinkToListTemplate method wants a ListTemplate object. LinkToListTemplate方法需要一个ListTemplate对象。 VBA isn't so choosy, it figures it out for the developer. VBA 不是那么挑剔,它为开发人员解决了这个问题。 The following works for me:以下对我有用:

Word.ListTemplate lt = null;
styl.LinkToListTemplate(lt); 

Note: While testing I noticed that doing this creates additional ListTemplates in the document.注意:在测试时,我注意到这样做会在文档中创建额外的 ListTemplates。 This can be a problem if you do it a lot in the one document.如果您在一个文档中做很多事情,这可能会成为一个问题。 In the version where ListTemplates were introduced (97, as I recall) it could corrupt files, or even crash them.在引入 ListTemplates 的版本中(我记得是 97),它可能会损坏文件,甚至使它们崩溃。 MS fixed that by having Word automatically delete unused LTs when a critical number accumulated. MS 通过让 Word 在累积临界数量时自动删除未使用的 LT 来修复该问题。 But it can affect file size.但它会影响文件大小。 Just FYI :-)仅供参考:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM