BuiltInDocumentProperties

B

Bongo

Hello

I created a Word document template from a document created at another
institution, and stupidly didn't notice that before there were hundreds of
documents in my organization's file system with the other company's name in
the "Company" BuiltInDocumentProperties.

I wrote the routine below to traverse the file tree and update each file. I
change the system time to the original modified time for each file so I don't
end up setting every file to be modified now.

HOWEVER, (A) this is insanely slow (even if I turn off
Application.ScreenUpdating; and (B) I noticed that from Windows Explorer, you
can modify these properties without opening the file.

Does anyone know either:

1) How I could improve the performance in general; or
2) Achieve the same result without having Word open each document?

Tx & rgds
Bongo


Sub Traverse(folderspec)
Dim fs, f, fl, fc, s, company
Dim realdate, realtime, filetime

realdate = Date
realtime = Time()
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files

For Each fl In fc
If fl.Type = "Microsoft Word Document" Then
filetime = fl.DateLastModified
Documents.Open FileName:=fl.Path
company = Documents(fl.Name).BuiltInDocumentProperties("Company")
If company = "OTHER COMPANY" Then
Time = filetime
Date = filetime
Documents(fl.Name).BuiltInDocumentProperties("Company") =
"MY COMPANY"
Documents(fl.Name).BuiltInDocumentProperties("Keywords") = ""
Documents(fl.Name).Save
End If
Documents(fl.Name).Close
End If
Next
' RECURSIVE PART, DISABLED FOR TESTING
' Set fc = f.subfolders
' For Each fl In fc
' Traverse (fl.Path)
' Next
Time = realtime
End Sub
 
J

Jezebel

There's a freebie application somewhere on the Microsoft site, that reads
and writes Office document properties. I've no idea whether it's faster. But
with only a few hundred documents to do, why worry about it. Leave it
running over night -- even at an insanely slow pace, they'll be done by
morning. And presumably you need to do it only once.
 
B

Bongo

Thanks Jezebel

I don't know if this is what you are referring to, but in fact there is an
API for modifying document properties without opening the files in the office
application. It is contained in "Dsofile.dll" and is available here:
http://support.microsoft.com/?id=224351. The performance is substantially
better than opening the file.

If anyone wants sample code, let me know.

Rgds
Bongo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top