[Tutor] Add metadata to a dir of files.
Mark Bystry
mabystry at verizon.net
Thu Feb 22 21:37:12 CET 2007
Well that's awesome. Thanks for the code. Unfortunately I cannot get it to run. After I installed
the win32 extensions for python...I get this error when trying to run.
Traceback (most recent call last):
File "C:\test.py", line 4, in <module>
props.SummaryProperties.Category = "CAT69"
File "C:\Program Files\Python25\Lib\site-packages\win32com\client\dynamic.py", line 534, in
__setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147024891), None)
code:
import win32com.client
props = win32com.client.Dispatch ("DSOFile.OleDocumentProperties")
props.Open (r"C:\test.txt")
props.SummaryProperties.Category = "CAT69"
props.Save ()
Maybe this is the same com error that you're getting
Mark
Tim Golden wrote the following on 2/22/2007 3:16 PM:
> Mark Bystry wrote:
>> getting even closer. figure out how to write to a file but still in vbscript.
>>
>> dsofile_write.vbs
>> code:
>> Set objFile = CreateObject("DSOFile.OleDocumentProperties")
>> objFile.Open("D:\test.txt")
>> objFile.SummaryProperties.Category = "CAT54"
>> objFile.Save
>
> In Python, that's spelt:
>
> <code>
> import win32com.client
> props = win32com.client.Dispatch ("DSOFile.OleDocumentProperties")
> props.Open (r"c:\temp\test.txt")
> props.SummaryProperties.Category = "CAT54"
> props.Save ()
>
> </code>
>
> but when I tried doing it, I got a COM error on the line
> where the Category is written. It worked ok with Subject
> instead. Wouldn't have thought this was down to Python,
> but I've not got much to go on!
>
> TJG
>
More information about the Tutor
mailing list