K
KHashmi316
I'm trying to automate the Import Data process somewhat; hence I
recorded the "IMPORT_DATA" macro below. I need a macro that does
everything in IMPORT_DATA *except* use the predetermined file path and
file name. That is, I want to be prompted to browse for or insert the
path and file name. Then, proceed with the rest of the IMPORT_DATA, as
seen below. How can this be done?
Thx for any info you can provide.
-KH
Sub IMPORT_DATA()
Cells.Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\Dell_Inspirion5100\G\household-appliances_com\eCost\10273764-eCOST_com_eZ_Affiliate_Program.txt"
_
, Destination:=Range("A1"))
..Name = "10273764-eCOST_com_eZ_Affiliate_Program"
..FieldNames = True
..RowNumbers = False
..FillAdjacentFormulas = False
..PreserveFormatting = True
..RefreshOnFileOpen = False
..RefreshStyle = xlInsertDeleteCells
..SavePassword = False
..SaveData = True
..AdjustColumnWidth = True
..RefreshPeriod = 0
..TextFilePromptOnRefresh = False
..TextFilePlatform = 437
..TextFileStartRow = 1
..TextFileParseType = xlDelimited
..TextFileTextQualifier = xlTextQualifierNone
..TextFileConsecutiveDelimiter = False
..TextFileTabDelimiter = False
..TextFileSemicolonDelimiter = False
..TextFileCommaDelimiter = False
..TextFileSpaceDelimiter = False
..TextFileOtherDelimiter = "|"
..TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
..TextFileTrailingMinusNumbers = True
..Refresh BackgroundQuery:=False
End With
ActiveWorkbook.Save
End Sub
recorded the "IMPORT_DATA" macro below. I need a macro that does
everything in IMPORT_DATA *except* use the predetermined file path and
file name. That is, I want to be prompted to browse for or insert the
path and file name. Then, proceed with the rest of the IMPORT_DATA, as
seen below. How can this be done?
Thx for any info you can provide.
-KH
Sub IMPORT_DATA()
Cells.Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;\\Dell_Inspirion5100\G\household-appliances_com\eCost\10273764-eCOST_com_eZ_Affiliate_Program.txt"
_
, Destination:=Range("A1"))
..Name = "10273764-eCOST_com_eZ_Affiliate_Program"
..FieldNames = True
..RowNumbers = False
..FillAdjacentFormulas = False
..PreserveFormatting = True
..RefreshOnFileOpen = False
..RefreshStyle = xlInsertDeleteCells
..SavePassword = False
..SaveData = True
..AdjustColumnWidth = True
..RefreshPeriod = 0
..TextFilePromptOnRefresh = False
..TextFilePlatform = 437
..TextFileStartRow = 1
..TextFileParseType = xlDelimited
..TextFileTextQualifier = xlTextQualifierNone
..TextFileConsecutiveDelimiter = False
..TextFileTabDelimiter = False
..TextFileSemicolonDelimiter = False
..TextFileCommaDelimiter = False
..TextFileSpaceDelimiter = False
..TextFileOtherDelimiter = "|"
..TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
..TextFileTrailingMinusNumbers = True
..Refresh BackgroundQuery:=False
End With
ActiveWorkbook.Save
End Sub