我在将Excel数据导入到Access中时总是提示"Worksheet"不能发现,但是我如果先用程序将Access中数据导入,再导入时就没有这种错误,请问这是什么原因?是不是我的数据访问组件版本过低?还是需要特殊的配置

解决方案 »

  1.   

    sheet后面要加$符号还有看你的sheet的名称是否正确!!
      

  2.   

    Workshee是EXCEL中的对象,你EXCEL引用了吗?对象定义正确吗?
      

  3.   

    go  ukyoxh(我来学习) (
    Sheet名称正确,加上$符号还是不行to  cuizm(射天狼) ( ) 
    对象都定义了,而且导入的如果是用我程序导出的Excel文件时就完全正常:(
      

  4.   

    On Local Error GoTo error
        Dim appExcel As New Excel.Application
        Dim wbExcel As New Excel.Workbook
        Dim temp As Excel.Worksheet
        Dim strTest As String
        comDlg.ShowOpen
        If comDlg.filename = "" Then
            Exit Function
        Else
            xlsFile = comDlg.filename
        End If    g_genConn.Execute "drop table temp"
        Set wbExcel = appExcel.Workbooks.Open(xlsFile) '打开Excel文件
        frmExcelsheet.Combo1.Clear '我在这里将Excel中的Sheet表加入到Combo1中
        For Each temp In wbExcel.Worksheets
            frmExcelsheet.Combo1.AddItem temp.Name
        Next
        If frmExcelsheet.Combo1.ListCount > 0 Then frmExcelsheet.Combo1.ListIndex = 0
        frmExcelsheet.show vbModal
        appExcel.Quit
        Set appExcel = Nothing
        Set wbExcel = Nothing
        Set temp = Nothing
        strTest = frmExcelsheet.returnStr  '返回用户选择的Sheet表名字
        If strTest = "" Then
            MsgBox "没有选择待导入的表!", vbCritical, "提示"
            Exit Function
        End If
        '清除完成
        If Rs.State Then Rs.Close
        '下面这一句话出错!!!!!!!!!!!!!!!!!!!!!!!!!!
        '提示我指定的Sheet表没有找到
        g_genConn.Execute "select * into temp from [excel 8.0;database=" & xlsFile & "].[" & strTest & "]"
      

  5.   


    appExcel.Quit
    Set temp = Nothing
    Set wbExcel = Nothing
    Set appExcel = Nothing
    end  sub
      放到最后试试
    我没做过excel做数据源   不过你在前边释放了所有excel资源