|
3#
楼主 |
发表于 2013-5-10 10:29:08
|
只看该作者
感谢楼上提供的思路。下面是我写的代码,两个问题都搞定了,谢谢您。
Sub a()
Dim getfile As String
Dim vfile As Variant
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim str As String
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
If .Show = True Then
For Each vfile In .SelectedItems
Set xlBook = xlApp.Workbooks.Open(vfile)
xlApp.Application.Visible = False
For i = 1 To xlBook.Sheets.Count
str = xlBook.Sheets(i).Name
DoCmd.TransferSpreadsheet acImport, 9, “a", vfile, True, str & "!" '全部导入表a
DoCmd.TransferSpreadsheet acImport, 9, str, vfile, True, str & "!" '按照sheet名称生成相应表
Next i
xlBook.Close
xlApp.Quit
Next vfile
End If
End With
End Sub |
|