2个回答
展开全部
不打开是不行的,至少得用代码打开。
sub test()
dim mary(1 to 1024,1 to 1),k as long,myFile as string
dim wb as workbook,sh as workSheet
myFile="D:\我的Excel文件.xls" '注:你文件的类型,可能是.xlsm或.xlsx格式,自行相应改动本行
k=0
set wb=workbooks.open(myfile)
for each sh in wb.worksheets
k=k+1
mary(k,1)=sh.name
next
wb.close 0
with activesheet
.[a1].resize(k,1)=mary
end with
end sub
sub test()
dim mary(1 to 1024,1 to 1),k as long,myFile as string
dim wb as workbook,sh as workSheet
myFile="D:\我的Excel文件.xls" '注:你文件的类型,可能是.xlsm或.xlsx格式,自行相应改动本行
k=0
set wb=workbooks.open(myfile)
for each sh in wb.worksheets
k=k+1
mary(k,1)=sh.name
next
wb.close 0
with activesheet
.[a1].resize(k,1)=mary
end with
end sub
展开全部
Sub AdoTs()
Dim cat
Dim cnn
Dim c
Set cnn = CreateObject("ADODB.Connection")
Set cat = CreateObject("ADOX.Catalog")
cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties='Excel 8.0';Data Source = " _
& ThisWorkbook.Path & "\abc.xls"
Set cat.ActiveConnection = cnn
For Each c In cat.Tables
Debug.Print c.Name
Next c
Set c = Nothing
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set cnn = Nothing
End Sub
用这个代码试下
Dim cat
Dim cnn
Dim c
Set cnn = CreateObject("ADODB.Connection")
Set cat = CreateObject("ADOX.Catalog")
cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties='Excel 8.0';Data Source = " _
& ThisWorkbook.Path & "\abc.xls"
Set cat.ActiveConnection = cnn
For Each c In cat.Tables
Debug.Print c.Name
Next c
Set c = Nothing
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set cnn = Nothing
End Sub
用这个代码试下
追问
你这个是不是在access下的,我要excel下的,最好在单元格中输出
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询