LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Importing a text file into spreadsheet

I have a text file that I receive once a month and the filename is not the same every month. I created a macro to import the text file, however, since the filename is not the same, I added some code to use an Open dialog box to select the file. I set fileToOpen as the filename that I open. I now need to have the macro import "fileToOpen". This is the code that Excel came up with for the importing of the text file. I need to tell it to import "fileToOpen". I just don't know how to do this. Any help would be great. Thanks. Matt (I tried replacing the two filenames with fileToOpen, but that didn't work. I may not have done it right though.

With ActiveSheet.QueryTables.Add(Connection:=
"TEXT;D:\JAN2004_MOMHP0000_135608.TXT", Destination:=Range("A1")
.Name = "JAN2004_MOMHP0000_135608
.FieldNames = Tru
.RowNumbers = Fals
.FillAdjacentFormulas = Fals
.PreserveFormatting = Tru
.RefreshOnFileOpen = Fals
.RefreshStyle = xlInsertDeleteCell
.SavePassword = Fals
.SaveData = Tru
.AdjustColumnWidth = Tru
.RefreshPeriod =
.TextFilePromptOnRefresh = Fals
.TextFilePlatform = xlWindow
.TextFileStartRow =
.TextFileParseType = xlDelimite
.TextFileTextQualifier = xlTextQualifierDoubleQuot
.TextFileConsecutiveDelimiter = Fals
.TextFileTabDelimiter = Fals
.TextFileSemicolonDelimiter = Tru
.TextFileCommaDelimiter = Fals
.TextFileSpaceDelimiter = Fals
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.Refresh BackgroundQuery:=Fals
End With
 
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 CSV file (saved as Text) into XL as Text -- over 60 colu sbp Excel Discussion (Misc queries) 1 October 14th 06 11:50 PM
Importing text file schildb Excel Discussion (Misc queries) 8 July 25th 06 10:57 PM
Importing text file, only option to edit existing file smokey99 Excel Discussion (Misc queries) 8 April 26th 06 09:08 PM
Importing a text file Bill Excel Discussion (Misc queries) 1 December 9th 05 07:00 PM
Importing text file Jillianno Excel Discussion (Misc queries) 1 February 16th 05 06:47 PM


All times are GMT +1. The time now is 09:08 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"