0x800a03ec {SaveAs method of Workbook class failed} error in TCOM/TCL

为君一笑 提交于 2019-12-12 02:18:25

问题


I'm trying to write some data from TCL to a CSV file, but i get the 0x800a03ec {SaveAs method of Workbook class failed} when executing it. Any idea why this is happening?

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

set workbooks [$application Workbooks]
set workbook [$workbooks Add]
set worksheets [$workbook Worksheets]
set worksheet [$worksheets Item [expr 1]]
#set worksheet [$worksheets Item "Sheet1"]
set cells [$worksheet Cells]

set rows [array size atten]
for {set row 1} {$row <= $rows} {incr row} {
    $cells Item $row "B" $atten($row)
}

$workbook SaveAs Filename {c:\tst.csv}
$application Quit

回答1:


The problem is in your SaveAs line. It should read

$workbook SaveAs {c:\tst.csv}

Also you may want to change the location from C:\ as that is often not a writable location,.




回答2:


Actually, plain googling for this yields lots of possible causes and solutions (from manual setting the output format to hitting the row limit to hitting the string length limit etc). Most definitely, this exception has nothing to do with Tcl (since it's just what COM marshals from an Excel instance), so just read through the discussions linked from the search output and see what applies to your case.



来源:https://stackoverflow.com/questions/9608253/0x800a03ec-saveas-method-of-workbook-class-failed-error-in-tcom-tcl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!