Question

I am having problems opening an existing Excel file with Tcl Tk. I am able to open an existing MS Word file with no problems. The code that I am using is as follows, also my test application has "package require tcom" included:

proc OpenFile {} {
#Path to file
set app [::tcom::ref getobject "C:\\Users\\Me\\Desktop\\Test.doc"] 
#Change path to application
set this [$app Application]
#Open application
$this Visible 1
}

This code is executed by a button. Basically, Test.doc gets opened after the button is pressed.

I tried changing the file to an existing Excel file, and when I press the button the file opens for a split second, and then closes. This also happens with MS Access files, as well.

Does anyone know how to open an existing Excel file with Tcl Tk, and make it stay open? Additionally, for PDFs and text files, I understand that I cannot use Tcom to open these files. Does anyone know how to open PDFs, text, and other non-MS files with Tcl Tk?

I really appreciate your help!

Thank you,

DFM

Was it helpful?

Solution

Assuming you're on Windows and you just want to open a file (.xls, .pdf, ...) with its usual application (ie. not modifying the file from your script) you can just use "start" like this:

set TestDoc "My Test.xls"
eval exec [auto_execok start \"\" [list $TestDoc]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top