|
我在论坛里找到一段代码,可以将指定的EXCL表导入TEMP表,但它的字段名是默认的,我希望使用导入的EXCL表的第一行作为字段名,请高手帮我改改,谢谢!
Private Sub ComChoseFile_Click()
On Error GoTo Err_ComChoseFile_Click
Dim strfilter, strdlgtitle, stropentitle, strfile As String
strfilter = "Excel 文件 (*.XLS)"
strdlgtitle = "选择后台数据库的文件"
stropentitle = "选择文件"
strfile = SelectFileName(strfilter, strdlgtitle, stropentitle)
If strfile = "" Then Exit Sub
TextName = Replace(strfile, Chr(9), vbCrLf)
Dim ex As Excel.Application
Dim exwbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Dim v
Set ex = CreateObject("Excel.Application")
Set exwbook = ex.Workbooks.Open(TextName)
For Each exsheet In exwbook.Worksheets
v = v & ";" & exsheet.Name
Next
v = Right(v, Len(v) - 1)
Me.Sheet.RowSource = v
exwbook.Save
exwbook.Close
ex.Quit
Set exsheet = Nothing
Set exwbook = Nothing
Set ex = Nothing
Sheet.SetFocus
Exit_ComChoseFile_Click:
Exit Sub
Err_ComChoseFile_Click:
Resume Exit_ComChoseFile_Click
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|