ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import Text file (https://www.excelbanter.com/excel-programming/322888-import-text-file.html)

Robert Christie[_3_]

Import Text file
 
Hi

Im trying to couple €śGetOpenFilname€ť with €śImport€ť Text file wizard.
i.e.
Open a folder, select a text file, and import into an ActiveSheet in tab
delimited form, Treating consecutive delimiters as one.

--
Thank you

Regards
Aussie Bob C.
Using Windows XP Home + Office 2003 Pro

Jim Rech

Import Text file
 
After you get the file's name with GetOpenFilename use the OpenText method
to open it.

--
Jim Rech
Excel MVP
"Robert Christie" wrote in message
...
| Hi
|
| I'm trying to couple "GetOpenFilname" with "Import" Text file wizard.
| i.e.
| Open a folder, select a text file, and import into an ActiveSheet in tab
| delimited form, Treating consecutive delimiters as one.
|
| --
| Thank you
|
| Regards
| Aussie Bob C.
| Using Windows XP Home + Office 2003 Pro



Robert Christie[_3_]

Import Text file
 
Hi Jim
Help says OpenText Method opens file in a new Workbook. I need to open in
Active Worksheet Cell A1.

TIA

Regards,
Aussie Bob C.

"Jim Rech" wrote:

After you get the file's name with GetOpenFilename use the OpenText method
to open it.

--
Jim Rech
Excel MVP
"Robert Christie" wrote in message
...
| Hi
|
| I'm trying to couple "GetOpenFilname" with "Import" Text file wizard.
| i.e.
| Open a folder, select a text file, and import into an ActiveSheet in tab
| delimited form, Treating consecutive delimiters as one.
|
| --
| Thank you
|
| Regards
| Aussie Bob C.
| Using Windows XP Home + Office 2003 Pro




Robert Christie[_3_]

Import Text file
 
Hi

Just for general interest this snippet of code works ok for me:

ChDir "C:\Data\Excel\School 2005\"
MyDataFile = Application.GetOpenFilename("Text Files,*.Txt")
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & MyDataFile, _
Destination:=Range("A1"))
.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 = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

Assuie Bob C.

"Robert Christie" wrote:

Hi Jim
Help says OpenText Method opens file in a new Workbook. I need to open in
Active Worksheet Cell A1.

TIA

Regards,
Aussie Bob C.

"Jim Rech" wrote:

After you get the file's name with GetOpenFilename use the OpenText method
to open it.

--
Jim Rech
Excel MVP
"Robert Christie" wrote in message
...
| Hi
|
| I'm trying to couple "GetOpenFilname" with "Import" Text file wizard.
| i.e.
| Open a folder, select a text file, and import into an ActiveSheet in tab
| delimited form, Treating consecutive delimiters as one.
|
| --
| Thank you
|
| Regards
| Aussie Bob C.
| Using Windows XP Home + Office 2003 Pro





All times are GMT +1. The time now is 04:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com