Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[tcom] Set excel document properties

72 views
Skip to first unread message

Peter Mayr

unread,
Jul 15, 2015, 5:19:48 PM7/15/15
to
Hello,

I can read the built in document properties with the following code
snippet. But how can I set it?


set application [::tcom::ref createobject "Excel.Application"]
$application Visible 1
$application DisplayAlerts 0

set workbooks [$application Workbooks]
set workbook [$workbooks Add]

set props [$workbook BuiltinDocumentProperties]
set prop [$props Item Company]
set propname [$prop Name]
set proptype [$prop Type]
set propval [$prop Value]

#$prop Value "New Value"

$application Quit
unset application

Olivier

unread,
Jul 16, 2015, 1:51:16 AM7/16/15
to

>
> #$prop Value "New Value"
>

According to the documentation ( http://docs.activestate.com/activetcl/8.6/tcom/tcom.n.html ) the answer is the above line, with Value = Name for instance, but it is commented, does it give an error ?

Peter Mayr

unread,
Jul 16, 2015, 2:37:44 PM7/16/15
to
Am 16.07.2015 um 07:51 schrieb Olivier:
>
>>
>> #$prop Value "New Value"
>>
>
> According to the documentation ( http://docs.activestate.com/activetcl/8.6/tcom/tcom.n.html ) the answer is the above line, with Value = Name for instance, but it is commented, does it give an error ?
>
With that line I always get Error "0x80020011 Does not support a
collection."

Peter Mayr

unread,
Jul 22, 2015, 12:42:49 PM7/22/15
to
I found the solution:
$prop Value [ ::tcom::na ] [ ::tcom::variant bstr "New Value" ]

Olivier

unread,
Jul 23, 2015, 4:31:07 AM7/23/15
to

>
> I found the solution:
> $prop Value [ ::tcom::na ] [ ::tcom::variant bstr "New Value" ]

I let things go because I don't have Excel, but finding this solution is not straightforward at all ! What clue did you use to find this structure , if I may allow to ask, something like :

[ [::tcom::info interface $prop ] properties ] ?

+ ::tcom::variant is not in the documentation ...

Anyway thanks for sharing the solution !!

Olivier.
0 new messages