使用VBA更新OneNote新建页面内容时遇Invalid XML错误
解决OneNote VBA更新页面时的“invalid XML”错误
问题根源
你的XML存在节点结构不符合OneNote schema的问题:在<one:OE>下的<one:Text>内部,不能嵌套<one:Text>节点,OneNote要求用<one:T>标签包裹文本内容。在线XML验证工具仅检查语法合规性,不会校验OneNote专属的结构约束,所以才会出现语法合法但OneNote报错的情况。
修正后的XML代码
<one:Page xmlns:one="http://schemas.microsoft.com/office/onenote/2013/onenote" ID="SOME ID"> <one:Title> <one:Text>Updated Page with Complex Content</one:Text> </one:Title> <one:Outline> <one:OEChildren> <one:OE> <one:Text> <one:ParagraphStyle>Body</one:ParagraphStyle> <one:T>Dummy Text</one:T> </one:Text> </one:OE> </one:OEChildren> </one:Outline> </one:Page>
额外注意事项
- 替换
ID="SOME ID"为OneNote页面的真实有效ID,占位符会导致更新操作失败。 - VBA传递XML字符串时,要确保双引号等特殊字符已正确转义,避免隐性解析错误。
内容的提问来源于stack exchange,提问作者BlueFlame
相关产品推荐
相关产品推荐

