[英]How to get the template path of a word 2003 document
When I create a new document based on a template (*.dot), I need to know on which template is the document based on.当我基于模板 (*.dot) 创建新文档时,我需要知道文档基于哪个模板。
Is there a way to find out with VBA which template was used for creating this new document?有没有办法通过 VBA 找出用于创建这个新文档的模板? I need the complete path to the template.
我需要模板的完整路径。
ActiveDocument.AttachedTemplate.FullName
You may also use a built-in document property to access the template name: ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)
您还可以使用内置文档属性来访问模板名称:
ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)
I don't remember why theres has been sometimes differences between the two results;我不记得为什么有时这两个结果之间存在差异。 you must try it out.
你必须试一试。 please be aware that accessing sometimes the built-in properties sets the document in a dirty state, so that it is useful to save the ActiveDocument.Saved state before and reset it after having accessed the property.
请注意,有时访问内置属性会将文档设置为脏 state,因此在访问该属性之前保存 ActiveDocument.Saved state 并在访问该属性后重置它是有用的。
[UPDATE] I've had again a look into the way you're creating the documents. [更新]我再次查看了您创建文档的方式。 If it's at your customer with 38.000 templates, I guess your problem are "fake" templates.
如果您的客户有 38.000 个模板,我猜您的问题是“假”模板。 I've just did a test with Office 2003:
我刚刚用 Office 2003 做了一个测试:
Sp I guess the documents "Without template" are only copies of other documents, and not of templates. Sp 我猜“没有模板”的文件只是其他文件的副本,而不是模板的副本。 So you have no way to find the base template.
所以你没有办法找到基础模板。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.