Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

BuiltInDocumentProperties

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bongo - 10 Feb 2006 06:55 GMT
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
Jezebel - 10 Feb 2006 07:08 GMT
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.

> Hello
>
[quoted text clipped - 58 lines]
>    Time = realtime
> End Sub
Bongo - 12 Feb 2006 12:10 GMT
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

> 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
[quoted text clipped - 64 lines]
> >    Time = realtime
> > End Sub
Doug Robbins - Word MVP - 12 Feb 2006 15:25 GMT
The use of the DSOFile.dll is discussed in the article "Getting access to
the Document Properties of a Word file" at:

http://www.word.mvps.org/FAQs/MacrosVBA/DSOFile.htm

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks Jezebel
>
[quoted text clipped - 85 lines]
>> >    Time = realtime
>> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.