不行的话直接用fso写吧,
我一直这样

解决方案 »

  1.   

    fso怎么写?给我个示例好吗?
      

  2.   

    '导出为Excel存储
    sub ExportToExcel(Param)
    if not window.confirm("导出为Excel文件吗?" & chr(13) & chr(10) & "提示:导出为Excel文件必须将IE本地安全级别设置为默认级别或者把自定义" & chr(13) & chr(10) & "          级别里第二个选项设置为禁用,否则Excel文件将直接保存到C盘目录下") then
    Exit sub
    end if

    dim webToExcelobj '这个是一个iframe网页的对象,
    set webToExcelobj = document.frames("MainFrame")

    if not isObject(EXPORT_OBJECT) then
    document.body.insertAdjacentHTML "afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>"
    end if
    '获取<html>*****</html>之间的内容
    for i = 0 to webToExcelobj.document.all.length - 1
    if webToExcelobj.document.all(i).tagName = "HTML" then
    WebToExcel webToExcelobj.document.all(i).outerHTML
    Exit for
    end if
    next
    end sub sub WebToExcel(htmlString)
    On Error Resume next
    dim fileName
    fileName = ExcelDescript

    if Trim(fileName) = "" then
    fileName = "HtmlToExcel"
    end if

    fileName = fileName & "_" & Report_ID
    fileName = fileName & "_"  & FormatDateTime(now, vbShortDate) & ""

    if not isObject(EXPORT_OBJECT) then
    document.body.insertAdjacentHTML "afterBegin","<OBJECT style='display:none' classid=clsid:0002E510-0000-0000-C000-000000000046 id=EXPORT_OBJECT></Object>"
    end if

    if isObject(EXPORT_OBJECT) then
    EXPORT_OBJECT.DataType = "HTMLData"
    EXPORT_OBJECT.HTMLData = htmlString
    EXPORT_OBJECT.ActiveSheet.Export "C:\" & fileName & ".xls", 0
    if Err.Number = 0 then
    alert( "导出成功!")
    end if
    else
    msgbox "导出为Excel文件失败,请确定已安装Excel2000(或更高版本)."
    end if
    end sub