Can you change the settings for an Import Wizard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to import a txt file into Excel. When I go through the wizard, I
choose "fixed Column" width- next- then I have to put my break lines in at
certain measurements. These txt files are always the same so is there a way
to change the default break line settings so they are where I want them to be
whenever I use the import wizard?
 
Since the .txt files you work with are always the same layout, maybe you could:

1. Start a new workbook
2. Record a macro when you open it and specify each field
3. Add headers/print layout/filters/subtotals, whatever else you can think of.
4. Add a button from the Forms toolbar to the first worksheet in that workbook.
5. Save this workbook.

Next time you need to import the text file, just open this workbook and click
the button.

With all the extra stuff you do in your macro (formatting, filters, freezepanes,
too), maybe you'll even like it better.

===
If the text file can change names, you can even have the macro ask for the name.

Your macro would change slightly, though:

Option Explicit
Sub testme()
Dim myFileName As Variant

myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.txt")

If myFileName = False Then
'do nothing
exit sub
End If

Workbooks.OpenText Filename:=myfilename, ....
'and the rest of your recorded code (including this modified .opentext line)

End Sub

If you have trouble tweaking your code, post back and I'm sure you'll get help.
 
Back
Top