简体   繁体   中英

How can I change extended file properties using vba

Using this link I was able to write a program in vba that reads extended file properties. Now, I'd like to make a program that can edit extended file properties - specifically property 22, the "subject" of a file. So, given a file path, how could you edit the subject associated with that file?

It can't be done using the method you are using now. You can install and use the Microsoft ActiveX dsofile.dll to both get and set extended properties using VBScript.

Set objFile = CreateObject("DSOFile.OleDocumentProperties")
objFile.Open("C:\My Path\MyFile.doc")
objFile.SummaryProperties.Subject = "My Subject"
objFile.Save
set objFile = Nothing

This is really more of a comment to jac above. The .dll file referenced won't work on 64 bit machines, and I feel most machines today are 64 bit. Click Here for an open source 64 bit equivalent to the referenced dsofile.dll.

' Make the file Read-Only

SetAttr "c:\temp\Sample.txt", vbReadOnly

' Make the file Hidden

SetAttr "c:\temp\Sample.txt", vbHidden

' Please note that if you change one attribute, the existing attribute is overwritten. For making a file as both readonly and hidden use both attributes in the function

SetAttr "c:\temp\Sample.txt", vbHidden + vbReadOnly

' Remove all atributes - convert a read-only file to read-write file, unhide the file etc

SetAttr "c:\temp\Sample.txt", vbNormal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM