select * from [sheet1$]
但是如果Sheet1的名字改为其他名字以后比如"Test",我在程序里也要将相应的部分改掉,即
select * from [Test$]
我想问一下是否有一种方法可以列举出EXCEL文件里所有的工作表名, 这样我就可以循环灵活的读取每个工作表里相应的内容了
5 个解决方案
#1
For lngIndex = 1 To xlswb.Worksheets.Count
Set xlsws = xlswb.Worksheets(lngIndex)
MsgBox xlsws.Name
Next lngIndex
Set xlsws = xlswb.Worksheets(lngIndex)
MsgBox xlsws.Name
Next lngIndex
#2
Dim EApp As New Excel.Application
Set EApp = New Excel.Application
EApp.Visible = True
Dim EBook As Excel.Workbook
Set EBook = EApp.Workbooks.Add
Dim i As Long
For i = 1 To EBook.Worksheets.Count
MsgBox EBook.Worksheets(i).Name
Next
Set EApp = New Excel.Application
EApp.Visible = True
Dim EBook As Excel.Workbook
Set EBook = EApp.Workbooks.Add
Dim i As Long
For i = 1 To EBook.Worksheets.Count
MsgBox EBook.Worksheets(i).Name
Next
#3
我用的是数据库连接ADO的方法连接EXCEL的,这种前提下有没有方法可以得到工作表名称呢?
#4
关注此问题,,,帮顶
#5
单纯ADO得不到的,就象单纯ADO你能得到MDB里的表名吗?
#1
For lngIndex = 1 To xlswb.Worksheets.Count
Set xlsws = xlswb.Worksheets(lngIndex)
MsgBox xlsws.Name
Next lngIndex
Set xlsws = xlswb.Worksheets(lngIndex)
MsgBox xlsws.Name
Next lngIndex
#2
Dim EApp As New Excel.Application
Set EApp = New Excel.Application
EApp.Visible = True
Dim EBook As Excel.Workbook
Set EBook = EApp.Workbooks.Add
Dim i As Long
For i = 1 To EBook.Worksheets.Count
MsgBox EBook.Worksheets(i).Name
Next
Set EApp = New Excel.Application
EApp.Visible = True
Dim EBook As Excel.Workbook
Set EBook = EApp.Workbooks.Add
Dim i As Long
For i = 1 To EBook.Worksheets.Count
MsgBox EBook.Worksheets(i).Name
Next
#3
我用的是数据库连接ADO的方法连接EXCEL的,这种前提下有没有方法可以得到工作表名称呢?
#4
关注此问题,,,帮顶
#5
单纯ADO得不到的,就象单纯ADO你能得到MDB里的表名吗?