我在单个工作簿中生成了六个用户想要的文本文件。首先,我打开第一个文件。当我打开后续文本文件并尝试将它们移动到第一个工作簿时,我得到了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.
有什么想法吗?