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: 1
Default Importing txt into XL as Delimited, what's wrong w my code?


Thanks Jim, I finally got it to work.

I recorded a new macro "inside the same workbook" i have been working
with. And copied and inserted the macro code into my code. And it works
like charm. This is what i have now.


Code:
--------------------

Private Sub wkscmd_ImportData_Click()

' Local Variables
Dim strPath As String, strFile As String

' Get Data file parameters
strPath = Me.Range("C1")
strFile = Me.Range("C2")

' Verify that table is empty
Me.Range("rdi_TableTop", "A" & Me.Range("A65536").End(xlDown).Row).EntireColumn.C learContents

' Open and import datafile
' Open file
Application.DisplayAlerts = False
On Error Goto Err_BadFileName
Range("rdi_TableTop").Select
With Selection.QueryTable
.Connection = "TEXT;" & strPath & strFile
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "*"
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Application.DisplayAlerts = True
Exit_BadFileName:
Exit Sub
Err_BadFileName:
MsgBox "Please enter the correct FilePath in CELL C1, e.g. C:\myfolder\ " _
& Chr(13) & "Be sure to have a slash behind your Filepath as shown above" _
& Chr(13) & "And enter the correct FileName in CELL C2, e.g. rawdata.txt", vbOKOnly + vbCritical, "Bad Filepath OR FileName"
Resume Exit_BadFileName

End Sub
--------------------


Thanks for your help and taking the time to look at my code :)


--
Mslady
------------------------------------------------------------------------
Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
View this thread: http://www.excelforum.com/showthread...hreadid=473001

 
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 MM:SS From Tab Delimited File and Charting Bryan Charts and Charting in Excel 4 July 28th 06 04:14 PM
Importing Comma delimited file Patsy Rogge Excel Discussion (Misc queries) 2 April 20th 06 02:50 PM
importing a tab delimited file rustypuckett Excel Programming 2 December 16th 04 02:25 AM
Importing tab delimited files into Excel dpimental Excel Programming 1 November 11th 04 04:17 PM
Problem Importing Delimited Data from IE Jim W. Excel Programming 1 September 3rd 03 06:54 PM


All times are GMT +1. The time now is 12:10 PM.

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"