Ive tried various combinations of puts below and get the following
puts [$builtinproperties Item "Title"]
::tcom::handle0x00C81E08
puts [$builtinproperties "Title"]
interface DocumentProperties does not have method or property Title
while executing
"$builtinproperties "Title""
invoked from within
"puts [$builtinproperties "Title"]"
Any suggestions? I have the equivalent VBScript working fine, but id
prefer to do it natively in TCL.
Thanks
Del
package require tcom
set xlsFile [file nativename [file join [pwd] del.xls]]
set excel [::tcom::ref createobj Excel.Application]
$excel DisplayAlerts False
set workbooks [$excel Workbooks]
set workbook [$workbooks Open $xlsFile]
set customproperties [$workbook CustomDocumentProperties]
set builtinproperties [$workbook BuiltinDocumentProperties]
# puts [$builtinproperties Item "Title"]
# puts [$builtinproperties "Title"]
# puts [$builtinproperties "Author"]
# puts [$builtinproperties Name]
# puts [$customproperties MyCustomeProp]
$workbook Close
$excel Quit
A bit of exploration shows that $builtinproperties is a collection (it
has the Item property).
So basically it is a "list" which you have to iterate over to get
objects with properties Name and Value:
::tcom::foreach x $builtinproperties {puts [$x Name]:[$x Value]}
How did I find out ? I used tcom's (and COM's) nice introspection
ability:
set in [::tcom::info interface $builtinproperties]
puts [$in properties]
puts [$in methods]
There, when you see props Item and Count, the object is indeed a
collection, mandating ::tcom::foreach to crack the hull open.
-Alex
Hi Alex,
Thanks, that works perfectly. Can now search list to get the Builtin
and Custom properties i want.
I then tried to repeat the experiment with Word.
I eventually got it to work.
The problem i was having is there is inconsistencies between Word and
Excel to get the BuiltIn Properties.
Its case sensitive!!
Excel requires this (Builtin)
set builtinproperties [$workbook BuiltinDocumentProperties]
Word requries this (BuiltIn)
set builtinproperties [$document BuiltInDocumentProperties]
Thanks
Del