Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automate text import

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Automate text import

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automate text import

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
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
Automate text import wizard in a protected sheet SNM Excel Discussion (Misc queries) 1 February 7th 08 02:58 PM
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
Automate Import/Export Steve Excel Discussion (Misc queries) 0 October 14th 05 06:38 PM
Automate the Text Import Wizard (Fixed Width) Yagnesh Excel Worksheet Functions 5 August 25th 05 08:08 PM
messy text file-- how to automate import? new_user Excel Programming 3 September 16th 03 07:57 PM


All times are GMT +1. The time now is 10:00 AM.

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"