Import ascii file

M

Mad Scientist

I'm puzzled because I'm trying to figure out a way to
write a macro to import ascii files from instruments into
my worksheets. I would like to be able to type the file
name into a text box and have it automatically import the
data to either a new sheet or existing worksheet. Does
anyone have any hints as to how I may bo about doing this?

Thanks in advance and science thanks you!

Mad Scientist
 
T

Tom Ogilvy

sPath = "C:\My Tools\My Instruments\"
workbooks.Open sPath & Sheet1.Textbox1.Text
 
M

mudraker

Try this

Dim sFile as string
sFile$ = Application.GetOpenFilename("Text Files (*.*),*.txt")
If sFile = False Then
End
End If
Workbooks.OpenText FileName:=sFile, Origin:=xlWindows _
, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(0, 1)
end sub
 
Top