强制保存文档及其引用文档

来源:互联网 发布:相声小品下载软件 编辑:程序博客网 时间:2024/05/08 19:12

Document.Save用来保存文档本身。如果需要同时保存其引用的文档,用Document.Save2。而缺省情况下,只有做了修改的文档才会被保存。Inventor会检查文档是否要保存,所以你会看到一个对话框弹出,列出了哪些文档需要保存。如果想无论有无修改,都保存,可强行设置Document.Dirty = True.  以下是一个简单的例子:


 ' 当前激活文档    Dim oDoc As Document    Set oDoc = ThisApplication.ActiveDocument        Dim oRefDoc As Document    Dim oRefDocDesc As DocumentDescriptor        ' 设置所有引用文档Dirty    For Each oRefDocDesc In oDoc.ReferencedDocumentDescriptors        Set oRefDoc = oRefDocDesc.ReferencedDocument        oRefDoc.Dirty = True    Next    ' 保存文档和引用文档.    Call oDoc.Save2(True)