Pdeters
asked on
import csv file into Access via VBA
I am using the following code to import an Excel File. I need import a csv comma delimited. How how do I need to change this
With fd
.Title = "Select file for import"
.Filters.Add "XLS File", "*.xls"
.InitialFileName = INITIAL_FOLDER
If .Show = -1 Then FilePath = .SelectedItems(1)
End With
Set fd = Nothing
docmd.TransferSpreadsheet , acSpreadsheetTypeExcel3, "Table1", FilePath, True
With fd
.Title = "Select file for import"
.Filters.Add "XLS File", "*.xls"
.InitialFileName = INITIAL_FOLDER
If .Show = -1 Then FilePath = .SelectedItems(1)
End With
Set fd = Nothing
docmd.TransferSpreadsheet , acSpreadsheetTypeExcel3, "Table1", FilePath, True
ASKER
I am looing to pulli n a csv file
docmd.TransferSpreadsheet , acSpreadsheetTypeExcel3, "Table1", FilePath, True
The file will be in the same format each time
docmd.TransferSpreadsheet , acSpreadsheetTypeExcel3, "Table1", FilePath, True
The file will be in the same format each time
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
.Title = "Select file for import"
.Filters.Add "XLS File", "*.xls"
.InitialFileName = INITIAL_FOLDER
If .Show = -1 Then FilePath = .SelectedItems(1)
End With
Set fd = Nothing
With ActiveSheet.QueryTables.Ad
"TEXT;" & FilePath, Destination:=Range("$A$1")
.Name = "CSV Data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
.TextFileTabDelimiter = False
.TextFileSemicolonDelimite
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumb
.Refresh BackgroundQuery:=False
End With