わかりました - これはあなたのため
を動作するはずです、私は私のシステム上でテストし、あなたのDoCmdコールは、おそらく古いMS-アクセスコードベースの要件を使用し、上の障害が発生していることを確認しました"。"そして、ファイル名の他の特殊文字は - おそらく何かが
ソリューションは、短いファイル名
がトップにこれを追加使用している拡張機能を把握するために、ファイル名の最初のドットを探すためにハードコードあなたのモジュールの
' Borrowed code from https://support.microsoft.com/en-us/kb/175512
#If VBA7 Then
Declare PtrSafe Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
#Else
Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
#End If
Public Function GetShortName(ByVal sLongFileName As String) As String
Dim lRetVal As Long, sShortPathName As String, iLen As Integer
'Set up buffer area for API function call return
sShortPathName = Space(255)
iLen = Len(sShortPathName)
'Call the function
lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
'Strip away unwanted characters.
GetShortName = Left(sShortPathName, lRetVal)
End Function
その後ショートバージョンにあなたのファイル名を変換するために、コードを変更
Dim filename As String
Dim filePath As String
Dim csvFile As String
filename = "Vol." & Year(Date) & "." & MonthName(Month(Date), True) & "." & Day(Date) & ".csv"
filePath = "C:\Users\House\Desktop\"
' Convert to Short Filename to work with old MS-Access code base
csvFile = GetShortName(filePath & filename)
Debug.Print csvFile
DoCmd.TransferText Transfertype:=acImportDelim, TableName:="Table1", filename:=csvFile, HasFieldNames:=True
使用しているコードを共有できますか? –
_____fileName = "Vol。" &Year(Date)& "。" &MonthName(月(日付)、True)& "。" &デイ(日)「& ".CSV" ______filePath = "C:\ユーザーは、ハウス\デスクトップ\ \" _____ DoCmd.TransferTextたtransferType:= acImportDelim、テーブル名:= "表1" は、ファイル名:= filePathに+ fileNameに、HasFieldNames:= True – Shreyans
質問のコードを更新し、コードの書式設定を使用してください。 –