F#Excel 12 Worksheet.Move()结果为HRESULT:0x800A03EC

时间:2014-07-25 20:09:14

标签: f# excel-2010

我在单个工作簿中生成了六个用户想要的文本文件。首先,我打开第一个文件。当我打开后续文本文件并尝试将它们移动到第一个工作簿时,我得到了HRESULT:0x800A03EC。

module ExcelFile

open Microsoft.Office.Interop.Excel

let Make fileNames (c:Config) =
    let xl = ApplicationClass()
    let openText fileName =
        xl.Workbooks.OpenText(Filename=fileName)
        xl.ActiveWorkbook

    let wb = openText (List.head fileNames)

    let make (fileName, n) =
        let b = openText fileName
        let ws = b.ActiveSheet :?> Worksheet
        // The following line raises the error.
        do ws.Move(After=(wb.Sheets.[wb.Sheets.Count]:?>Worksheet).Name)
        // Lots of formatting and prettifying follow...

    let fileNames' = List.tail fileNames
    let ts = List.zip fileNames' [1.. List.length fileNames']
    do List.iter make ts
    // Save, etc.

有什么想法吗?

0 个答案:

没有答案