not quite random
nothing in particular

 


December 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Nov   Jan










Subscribe to "not quite random" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

jenett.radio.randomizer - click to visit a random Radio weblog - for information, contact randomizer@coolstop.com

Blogchalk:
Portsmouth, NH, US




 

Friday, December 27, 2002

Using Python to Extract Title from MS Word Doc

Based on some code from this article, here's how to extract the "Title" property from a Word document in python.

  import win32com.client
  app = win32com.client.Dispatch('Word.Application')
  doc = app.Documents.Add(self.filename)
  self.title = doc.BuiltinDocumentProperties("Title")
  doc.Close(0)
  app.Quit()
3:25:43 PM   #  

Hmm.

Hmm. There has got to be a faster way of getting that info. I'm pretty sure that Explorer isn't launching Word every time it wants to display the properties for a document.

3:47:27 PM   #  

Document Titles Part II: A Better Way

There is: FPropSet. This is about two magnitudes of order faster than the previous solution.

    fps = win32com.client.Dispatch('FilePropertySet.FilePropertySet')
    fps.Pathname = file
    print fps.BuiltInFileProperties().Item("Title")
6:30:51 PM   #  

Do Not Operate Heavy Machinery if Brain is not Working

After spending an hour trying to figure out what misunderstanding of COM was causing my problem, I realized that the file I was trying to test against DID NOT EXIST (typo). I was calling everything correctly, but the information I was sending was wrong... note that setting fps.Pathname to a non-existent file will cause an exception.

6:33:41 PM   #  


Click here to visit the Radio UserLand website. © Copyright 2003 Brian St. Pierre.
Last update: 1/3/2003; 8:34:44 AM.