特急VB控制EXCEL高手请进(在线等)
下面这段代码为什么不能关闭EXCEL文件啊!
当我执行下面的代码后我要把这个EXCEL文件添加到数据库中
就是下面的这个语句 可是他总是说无法启动应用程序,或被其它用户以独占方式打开
strsql = "SELECT * into " & strLanguageName & " FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',"
strsql = strsql & "'Data Source=" & sExcelPath
strsql = strsql & ";User ID=sa;Password=sunjian;Extended properties=Excel 8.0')..." & sSheetName & "$"
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlQuery As Excel.QueryTable
Set xlApp = CreateObject("Excel.Application")
Set xlBook = Nothing
Set xlBook = xlApp.Workbooks().Open(Trim(txtPath.Text))
Set xlSheet = xlBook.Sheets(1)
xlApp.Visible = True
If Dir(txtPath.Text) <> "" Then '由VB关闭EXCEL
' xlApp.Workbooks(1).Save
xlApp.Workbooks(1).Close (txtPath.Text) ' 关闭工作簿
'xlBook.Close (True) '关闭EXCEL工作簿
xlApp.Quit '关闭EXCEL
End If