VBA读取、增加自定义和修改文档属性

读取系统文档属性

Sub read()
On Error Resume Next
rw = 1
Worksheets(1).Activate
For Each p In ActiveWorkbook.BuiltinDocumentProperties
    Cells(rw, 1).Value = p.Name
    Cells(rw, 2) = p.Value
    rw = rw + 1
Next
End Sub

读取自定义文档属性

Sub Macro1()

 Cells(1, 2) = ActiveWorkbook.CustomDocumentProperties("完成日期").Value

End Sub

增加自定义属性

Sub add()
    ActiveWorkbook.CustomDocumentProperties.add Name:="完成日期", Type:=msoPropertyTypeDate, LinkToContent:=False, Value:="31/12/2009"
End Sub

修改

Sub modf()
     ActiveWorkbook.BuiltinDocumentProperties("Last Save Time").Value = "31/12/2009"
End Sub

删除

Sub del()
    ActiveWorkbook.CustomDocumentProperties("完成日期").delete
End Sub

posted @ 2014-06-15 10:33  dzqabc  阅读(1334)  评论(0编辑  收藏  举报