使用 Tcl Tk 打开 Excel 和 PDF 文件

发布于 2024-08-09 10:32:06 字数 612 浏览 0 评论 0原文

我在使用 Tcl Tk 打开现有 Excel 文件时遇到问题。我可以毫无问题地打开现有的 MS Word 文件。我正在使用的代码如下,我的测试应用程序也包含“package require tcom”:

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
}

此代码由按钮执行。基本上,按下按钮后 Test.doc 就会打开。

我尝试将文件更改为现有的 Excel 文件,当我按下按钮时,文件会打开一瞬间,然后关闭。 MS Access 文件也会发生这种情况。

有谁知道如何使用 Tcl Tk 打开现有的 Excel 文件并使其保持打开状态?此外,对于 PDF 和文本文件,我了解我无法使用 Tcom 打开这些文件。有谁知道如何使用 Tcl Tk 打开 PDF、文本和其他非 MS 文件?

我真的很感谢你的帮助!

谢谢你,

东风公司

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2024-08-16 10:32:06

假设您在 Windows 上并且只想使用常用应用程序打开一个文件(.xls、.pdf 等)(即不从脚本修改文件),您可以像这样使用“start”:

set TestDoc "My Test.xls"
eval exec [auto_execok start \"\" [list $TestDoc]

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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文