vba - 从 vba 导入 csv 文件而不提供表名
问题描述
我正在尝试将 csv 文件从目录导入访问数据库。我可以导入,但每当我导入文件名时,文件名都会更改,我不想更改文件名。我希望表名与 csv 文件同名。我该怎么做呢?这是我的代码:strInitialDirectory = "S:\"
strPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:=strBrowseMsg, _
Flags:=ahtOFN_HIDEREADONLY)
If strPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Sub
End If
' Replace tablename with the real name of the table into which
' the data are to be imported
strTable = strPathFile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTable, strPathFile, blnHasFieldNames
End Sub
如果 csv 文件名是 StudentRecords18/19.csv,那么表名也应该是 StudentRecords18/19。我可以在 strtable 中设置它,但我不想这样做,因为我每个月都会导入不同的数据,因此它将包含相同的表名,最后是 1 等等,但数据不同..
解决方案
推荐阅读
- android - 如何修复“无法加载 AppCompat ActionBar 并出现未知错误”。对于 api 28?
- facebook - 如何在 Spring Boot 中获取 facebook oauth 访问代码?
- javascript - 如何对混淆为十六进制表示的 javascript 变量进行反混淆?
- cs-cart - cs购物车全局选项批量添加到类别中的产品
- ibm-midrange - IBM i - DDS 用于显示文件和物理文件
- oracle - 我可以在程序中一次创建具有不同名称的表吗
- r - R中的group_by错误“赋值目标扩展为非语言对象”
- c# - RestSharp 匹配 Curl 语法
- c# - 其他属性依赖于它的值的惰性 getter 属性的最佳方法
- javascript - 滚动时的粘性标题并在我向上滚动时显示