次の形式の CSV ファイルがあります。
Dates,Open,High,Low,Close,Volume
#2010-01-03 15:01:00#,1.1648,1.1648,1.1622,1.1646,8
#2010-01-03 15:02:00#,1.1648,1.1648,1.1648,1.1648,1
#2010-01-03 15:03:00#,1.1648,1.1648,1.1648,1.1648,2
編集:明確にするために、それはYYYY-MM-DD
.
次のスクリプトを使用してAccess 2010にインポートすると( にありますD:\Data\Processed
):
Dim strFolderPath As String
strFolderPath = "D:\Data\Processed\"
Dim StrFile As String
StrFile = Dir(strFolderPath & "*.txt")
Do While Len(StrFile) > 0
'MsgBox (objF1.Name)
DoCmd.TransferText acImportDelim, , StrFile & "draft", strFolderPath & StrFile, True
'DoCmd.TransferText acImportDelim, strFolderPath & objF1.Name, False
'DoCmd.TransferText acImportDelim, "TextImportSpecs", "tblImportedFiles", strFolderPath & objF1.Name, False
'DoCmd.TransferText _
'TransferType:=intImportType, _
'SpecificationName:=strSpecification, _
'TableName:=strTable, _
'FileName:=strPath & strFile, _
'HasFieldNames:=blnHasFieldNames
'strFile = Dir
Name strFolderPath & StrFile As "D:\Data\Done\" & StrFile 'Move the files to the archive folder
StrFile = Dir
Loop
最初のフィールドを日付ではなく文字列としてインポートします。テキスト ファイルの形式を変更するか (推奨)、日付/時刻オブジェクトとしてインポートできるようにスクリプトを変更していただければ幸いです。