What is wrong with this syntax?

Hunden

New Member
Joined
Nov 4, 2008
Messages
35
Hey guys. Why dosnt this syntax import data from the file I choose?



Sub Makro1()

Dim filename As String

filename = Application.GetOpenFilename("Text Files (*.tsp),*.tsp", , "Please selec text file...")

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;filename", _
Destination:=Range("$B$7"))

.Name = "a280"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
End With
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Perhaps because you aren't actually including the chosen filename.:)
Rich (BB code):
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & filename, _
Destination:=Range("$B$7"))
 
Upvote 0
Perhaps because you aren't actually including the chosen filename.:)
Rich (BB code):
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & filename, _
Destination:=Range("$B$7"))

Hmm... it still dosnt work :(
 
Upvote 0
Please tell how it doesn't work.:)

By the way why are you using this method in the first place?

Why not try OpenText?
 
Upvote 0
Please tell how it doesn't work.:)

By the way why are you using this method in the first place?

Why not try OpenText?


If you got a better solution, fell free to give me it :p
But i dont know why it dosnt work. It just dont copy any data into the excel doc.
 
Upvote 0
try

Code:
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & filename, _
Destination:=Range("$B$7")) ' Changed ("TEXT;" & filename)
~~~~~~~~
     .TextFileSpaceDelimiter = False
     .Refresh  (Added)
 
Upvote 0
try

Code:
With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & filename, _
Destination:=Range("$B$7")) ' Changed ("TEXT;" & filename)
~~~~~~~~
     .TextFileSpaceDelimiter = False
     .Refresh  (Added)

Thanks alot. It work now. But why? im lost:D

Regards
 
Upvote 0

Forum statistics

Threads
1,217,344
Messages
6,136,019
Members
449,977
Latest member
altizerc2196

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top