|
先做了一个空文件,用下面的程序增加,更改了文件的实际自定义属性。但发现用excel直接打不开了。
Sub propertiesshow2()
Dim rw As Integer
Dim p
rw = 1
On Error Resume Next
Dim wb As Workbook
Set wb = GetObject("E:\test2.xlsx")
wb.CustomDocumentProperties.Add Name:="bbb", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=100
wb.CustomDocumentProperties.Add Name:="bbb1", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=200
wb.CustomDocumentProperties.Add Name:="bbb2", LinkToContent:=False, Type:=msoPropertyTypeString, Value:=300
For Each p In wb.CustomDocumentProperties
Cells(rw, 1).Value = p.Name
Cells(rw, 2).Value = p.Value
If p.Name = "bbb" Then p.Value = 1000000
rw = rw + 1
Next
wb.Save
wb.Close
End Sub
|
|