1

I have an application which use tcom library to access COM object. In the end of my program, I'm trying to delete the COM object. Following is my reference.

http://wiki.tcl.tk/11900

Here's my program

  package require tcom

  # create COM objec
  set application [::tcom::ref createobject "MyApplication"]

  # unbind and release COM object 
  ::tcom::unbind  $application 
  set application {}
  $application Quit 
  unset application 

And the result turns out to be

  object does not implement method or property Quit

How to delete the COM object correctly?

1
  • By the way, I use TCL version 8.4 Commented Aug 23, 2015 at 4:35

2 Answers 2

1

I don't know anything about tcl but I do know about COM. Your object application does not implement a method Quit as it says.

however

unset application 

will delete the COM object and unload it from memory.

If the object also has a close or exit method you could call that first, but you would need to check the docs for application object.

Sign up to request clarification or add additional context in comments.

1 Comment

Ensure you unset all variables you got directly or indirectly from MyApplication - preferably with application last. But it all does depend what application you are talking about.... Word? Outlook?
0

It looks to me as if you have these 2 lines the wrong way round:

  set application {}
  $application Quit 

You reset application and then try and use it.

However as Donal points out below this would not result in the error message that you are getting and I suspect that your application MyApplication does not implement actually implement a Quit method.

You can use tcom to find out what methods and properties an interface defines, for example the following code does this for Excel.

package require tcom
set excel [::tcom::ref createobj Excel.Application]

set iface [::tcom::info interface $excel]
foreach {method} [$iface methods] {
    puts $method
}

puts "--"
foreach {property} [$iface properties] {
    puts $property
}

$excel Quit
unset excel

This should allow you to see the methods and their parameters and the properties that MyApplication actualy does expose, if there isn't a Quit method then you'll need to go back to the owner of the application and find out what method, if any, needs to be invoked through the com interface to terminate the application.

2 Comments

That will indeed not work, but won't (I hope!) result in the error that the questioner mentions.
Indeed, the code given would likely result in an 'ambiguous command name' error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.