且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何确定文档是否为模板?

更新时间:2023-11-25 11:09:16

感谢kmote,我找到了解决方案.

Thanks to kmote, I found the solution.

只需签入 SaveFormat 属性,如果该文档是模板(这里是此属性的可能值列表.

Just check in the SaveFormat property if the document is a Template (here is the list of possible values for this property).

Private Function isTemplate(ByVal Doc As Document) As Boolean
  Select Case Doc.SaveFormat
    Case wdFormatTemplate, wdFormatDocument97, _
         wdFormatXMLTemplate, wdFormatXMLTemplateMacroEnabled, _
         wdFormatFlatXMLTemplate, wdFormatFlatXMLTemplateMacroEnabled
      isTemplate = True
    Case Else
      isTemplate = False
  End Select
End Function