LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Importing CSV as text

This is one way to call the file

Answr = InputBox("Feed the file name", FName)
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\userID\Desktop\" & FName & ".csv",
Destination:=Range("A1"))
....

You could also have the user to feed the filename to a cell in a worksheet.
To get the value from there use this type of code:

Fname = Sheets("Sheet1").Range("B2").Value

Mika Oukka

"Rudy Woltner" wrote in message
...
I'm trying to set up a script to import a CSV with every column formatted

as
text to avoid loss of leading zeros that may be part of an actual barcode

or
asset ID. The CSV file itself comprises of close to 100 columns. I would

also
like to be able to ask the user for the file name and path as part of the
import.

I've tried several test scenarios using small CSV files and recording the
action, but I've been having trouble calling the file name.

Here is what I get when recording:

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\userID\Desktop\test.csv",
Destination:= _
Range("A1"))
.Name = "test"
.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 = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileCommaDelimiter = True
.TextFileColumnDataTypes = Array(2, 2, 2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

I would like to be able to replace the "C:\Documents and
Settings\userID\Desktop\test.csv" with the user's selected file and path.
--
Thanks,
R Woltner



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing text with text qualifier slusby Excel Discussion (Misc queries) 1 May 22nd 09 06:43 PM
Importing Text Snailspace Excel Discussion (Misc queries) 3 July 15th 08 07:52 PM
Importing text--cell text limit? Scout Excel Discussion (Misc queries) 1 July 2nd 08 08:38 PM
Importing text Paul Hyett[_2_] Excel Discussion (Misc queries) 4 July 11th 07 09:03 AM
Importing CSV file (saved as Text) into XL as Text -- over 60 colu sbp Excel Discussion (Misc queries) 1 October 14th 06 11:50 PM


All times are GMT +1. The time now is 09:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"