I have a macro that is supposed to import a downloaded csv file into a worksheet in my primary workbook. Currently, it only imports the csv file if it has been opened and saved before importing. I apologize in advance if this has been answered in previous posts, but I couldn't find the right keywords to find the information I was looking. The code below is what I am using.
Sub Import_DX()
Dim f as Variant
f = Application.GetOpenFilename(filefilter:="CSV Files (*.csv), *.csv")
If f = "False" Then Exit Sub
With Worksheets("DX Import").QueryTables.Add(Connection:= _
"TEXT;" & f, Destination:=Worksheets("DX Import").Range("$A$1"))
.Name = "DXI"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 1, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Respectfully
Sub Import_DX()
Dim f as Variant
f = Application.GetOpenFilename(filefilter:="CSV Files (*.csv), *.csv")
If f = "False" Then Exit Sub
With Worksheets("DX Import").QueryTables.Add(Connection:= _
"TEXT;" & f, Destination:=Worksheets("DX Import").Range("$A$1"))
.Name = "DXI"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(9, 1, 1, 9, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Respectfully