Sign in to follow this  
Followers 0
ard

txt file to excel using the import wizard

3 posts in this topic

Hi every one,

I need some help with a sricpt that list user's text files in one directory then opens them with excel.

my problem is that I need the text file to be imported via the Text import wizard.

can some one help please.. :whistle:

Share this post


Link to post
Share on other sites



Just make the text file a CSV file.

Then if you open it, it will automatic be devided in colums etc.

Share this post


Link to post
Share on other sites

Just make the text file a CSV file.

Then if you open it, it will automatic be devided in colums etc.

This does not work as the user's need to change output via the import wizard, this is the macro code I found, but can not get to work via Auto.

'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Sub ImportTextUsingXlDialogOpen()

'\ use this approach to prompt user for text wizard values

Application.ScreenUpdating = False

Application.DisplayAlerts = False

'\ display open file dialog and copy to new (temporary workbook)

'On error resume next - traps for user clicking cancel in the import dialog

'Error number is 1004 - is so exit the procedure

On Error Resume Next

If Application.Dialogs(xlDialogOpen).Show("C:\Magix\*.txt") Then

If Err.Number = 1004 Then

Exit Sub

End If

ActiveSheet.UsedRange.Select '\ select imported text in temporary workbook

Selection.Copy '\ copy to clipboard

ActiveWorkbook.Close '\ close temporary workbook

Worksheets.Add

Range("A1") = "Dialogs(xlDialogOpen) Method"

Range("A2").Select

ActiveSheet.Paste '\ paste text into your workbook

End If

Application.ScreenUpdating = True

Application.DisplayAlerts = True

End Sub

'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0