Word 2007 VBA:ActiveDocument.CustomXMLParts [英] Word 2007 VBA: ActiveDocument.CustomXMLParts

查看:121
本文介绍了Word 2007 VBA:ActiveDocument.CustomXMLParts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本教程(以及还有很多),在CustomXMLParts对象集合Load方法中有一个整数,我找不到解释. Word 2007 VBA参考似乎也没有列出Load方法:

In this tutorial (and many others), there's an integer in the CustomXMLParts object collection Load method that I can't find an explanation for. The Word 2007 VBA Reference doesn't seem to list the Load method either:

  ''# Load CustomerData.xml file
  ActiveDocument.CustomXMLParts.Add
  ActiveDocument.CustomXMLParts(4).Load ("c:\CustomerData.xml") 

4 代表什么?

推荐答案

每个.docx中始终存在三个内置CustomXMLParts(由Word 2007/2010创建-不一定是创建的.docx通过Open XML SDK).即:

There are always three built-in CustomXMLParts in every .docx (created by Word 2007/2010 - not necessarily a .docx created by the Open XML SDK). Namely:

<cp:coreProperties xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"><dc:creator></dc:creator><cp:keywords/><dc:description/><dc:subject/><dc:title/><cp:category/><cp:contentStatus/></cp:coreProperties>

<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"><Company/><Manager/></Properties>

<CoverPageProperties xmlns="http://schemas.microsoft.com/office/2006/coverPageProps"><PublishDate/><Abstract/><CompanyAddress/><CompanyPhone/><CompanyFax/><CompanyEmail/></CoverPageProperties>

因此,4在这里仅意味着在完成ActiveDocument.CustomXMLParts.Add之后添加第四个获得第四个".如果您有更多索引,则只需使用下一个可用的索引号.代替4,我可能只使用它:

So 4 here just means, after you've done ActiveDocument.CustomXMLParts.Add to add a fourth one "get the fourth one". If you had more, you would just use the next available index number. Instead of 4, I'd probably just use this instead:

Dim ap As Document
Set ap = ActiveDocument
ap.CustomXMLParts.Add
ap.CustomXMLParts(ap.CustomXMLParts.Count).Load ("C:\CustomerData.xml")

这篇关于Word 2007 VBA:ActiveDocument.CustomXMLParts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆