ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import ascii file (https://www.excelbanter.com/excel-programming/287165-import-ascii-file.html)

Mad Scientist

Import ascii file
 
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

Tom Ogilvy

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

--
Regards,
Tom Ogilvy

Mad Scientist wrote in message
...
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




mudraker[_76_]

Import ascii file
 
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


---
Message posted from http://www.ExcelForum.com/



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

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