LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Automatically Parsing Fixed-width Text Import

Thanks again, Dave. Works fine!
Cheers,
Bill
"Dave Peterson" wrote in message
...
Record a macro when you do it once. But then modify the macro to show
that
File|open dialog.

When you recorded your macro, you got something that looked like:

Option Explicit
Sub Macro1()

Workbooks.OpenText Filename:="C:\myfile.txt", Origin:=437,
StartRow:=1,...

End Sub

Well, instead of having your filename in the code, you can give the user a
chance to pick it themselves (take a look at getopenfilename in VBA's
help):

Sub macro1A()

Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Text Files,
*.Txt", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.OpenText Filename:=myFileName '....rest of recorded code
here!

End Sub

You may have to tweak some other code--depending on how much other stuff
you did
in your recorded macro.

If you have trouble, post back with a question.

Bill wrote:

I want to automate this function for a daily feed of a text file with
fixed
width fields. Ther are about thirty column breaks to select and this
would
be a real pain to have to do every day. I know I can record a macro, but
I
want to start the process after the File Open dialog. My VBA skills are
effectively non-existent but if I had some code I could probably modify
it
to my needs. Can someone please point me in the right direction. .


--

Dave Peterson



 
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
Fixed Width Text Import Settings Bryan Excel Discussion (Misc queries) 4 July 8th 08 12:15 AM
Repeatable Fixed Width Import donnie darko Excel Discussion (Misc queries) 9 December 6th 06 06:47 PM
HOW DO YOU SET THE DEFAULT FIXED COLOMN WIDTH ON THE EXCEL IMPORT Robert Belote Excel Discussion (Misc queries) 0 May 5th 06 08:33 PM
Automate the Text Import Wizard (Fixed Width) Yagnesh Excel Worksheet Functions 5 August 25th 05 08:08 PM
Import *.asc file into excel fixed width Hartsell Excel Programming 1 February 24th 04 08:15 AM


All times are GMT +1. The time now is 05:45 PM.

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"