2013-05-06 40 views
2

我已經寫了下面的代碼轉換XLSX文件,以CSV格式:得到錯誤800a03ec在打開Excel文件

If WScript.Arguments.Count < 2 Then 
    WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv" 
    Wscript.Quit 
End If 

Dim oExcel 
Set oExcel = CreateObject("Excel.Application") 
Dim oBook 
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0)) 
oBook.SaveAs WScript.Arguments.Item(1), 6 
oBook.Close False 
oExcel.Quit 

這是工作正常,當我給服務器路徑XLSX文件。但是,當我給本地計算機路徑,它給我以下錯誤:

File could not be found. Check the spelling of the file name, and verify that file location is correct. If you are trying to open the file from list of most recently used files, make sure that file has not been renamed, moved or deleted
code: 800A03EC
Source: Microsoft Office Excel

+0

請在提交問題或答案之前查看預覽。 – 2013-05-06 07:46:41

+0

你稱之爲「服務器路徑」和「本地機器路徑」是什麼?請向我們展示您的命令行。 – 2013-05-06 11:55:04

+0

我與MS Office Professional Plus 2010的問題完全相同 – 2013-07-04 09:23:37

回答

3

如果您仍然收到此錯誤,我會做雙方的論據簡單的回聲,以確保他們在做什麼他們應該,如果您使用Cscript.exe來運行它做

wscript.echo "Arg(0): " & WScript.Arguments.Item(0) & " Arg(1): " & WScript.Arguments.Item(1) 

此外,默認情況下會尋找在C文件:\ WINDOWS \ system32 \目錄下

+0

以及如何修改此默認位置?當我將文件複製到這個位置時,我也得到了完全相同的錯誤:D – 2013-07-04 09:24:11

3

在任何情況下使用類似的問題發現這一點,錯誤代碼似乎是一個普遍的Excel錯誤,這意味着什麼它無法打開文件。

在我的情況下,我試圖手動打開相同的文件,發現Excel想修復損壞的文件。我被允許用不正確的驗證保存它,但它不會以編程方式打開。用手打開它意味着它可以向我展示一個對話,詢問我是否想修復它。

0

在我的情況下,相應的消息是「無法設置PageSetup類的PaperSize屬性」。如果標準打印機不支持Excel工作簿/工作表的頁面格式,則會發生這種情況。