Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. I'm new to writing macros, and I've been asked to write a macro that imports colon delimited text files into excel. I need to create the macro so that the user is prompted for the file to import. I used the macro recorder, but I cannot get it to work using a variable. Can anyone lend a hand
-Jamie |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jami
Is this the type of thing that you mean Ton getfilename = InputBox("Enter the file name including path", , "c:\temp\aaa.txt" Workbooks.OpenText FileName:=getfilename, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False , Space:=False, Other:=True, OtherChar:=":", FieldInfo:=Array(Array(1, 1 ), Array(2, 1), Array(3, 1) ----- Jamie Abbamont wrote: ---- Hi. I'm new to writing macros, and I've been asked to write a macro that imports colon delimited text files into excel. I need to create the macro so that the user is prompted for the file to import. I used the macro recorder, but I cannot get it to work using a variable. Can anyone lend a hand -Jamie |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jamie
Try this version Gives user normal Open file dialog box Sub OpenFile() 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:=xlDelimited, TextQualifier:=xlDoubleQuote, _ ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False, Comma:=True _ , Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _ Array(3, 1), Array(4, 1)) End Sub --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automate text import wizard in a protected sheet | Excel Discussion (Misc queries) | |||
Would Like to Automate Batch File Creation and Text FIle Import | Excel Discussion (Misc queries) | |||
Automate Import/Export | Excel Discussion (Misc queries) | |||
Automate the Text Import Wizard (Fixed Width) | Excel Worksheet Functions | |||
messy text file-- how to automate import? | Excel Programming |