G
Guest
Within an application that I am writing, I am trying to allow the user to select a text (.txt) file from the Open File dialog box in Excel. This is working.
The problem is, I want to eliminate the user from having to go through the 3-step Text Import Wizard, which appears right after user selects the (.txt) file from the Open File dialog box. I want to suppress this Wizard from appearing and do that work behind the scenes in the programming.
Code to display the Open File dialog box that works:
With Application
.DefaultFilePath = ("*.*") 'Show all file types in Open File dialog box
.Dialogs(xlDialogOpen).Show 'Show open dialog box to select text file
.DefaultFilePath = strMyFilePath 'Reset original default file path
End With
Code to suppress Wizard and do delimiting by Tab behind the scenes which doesn’t work:
strFileName = ActiveWorkbook.Name
Application.DisplayAlerts = False
Workbooks.OpenText FileName:= _
strFileName, Origin _
:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, Tab:=True
Application.DisplayAlerts = True
The second group of code works but the Wizard opens first and you have to go through the step process in the Wizard before the second group of code is executed.
Can you help?
The problem is, I want to eliminate the user from having to go through the 3-step Text Import Wizard, which appears right after user selects the (.txt) file from the Open File dialog box. I want to suppress this Wizard from appearing and do that work behind the scenes in the programming.
Code to display the Open File dialog box that works:
With Application
.DefaultFilePath = ("*.*") 'Show all file types in Open File dialog box
.Dialogs(xlDialogOpen).Show 'Show open dialog box to select text file
.DefaultFilePath = strMyFilePath 'Reset original default file path
End With
Code to suppress Wizard and do delimiting by Tab behind the scenes which doesn’t work:
strFileName = ActiveWorkbook.Name
Application.DisplayAlerts = False
Workbooks.OpenText FileName:= _
strFileName, Origin _
:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, Tab:=True
Application.DisplayAlerts = True
The second group of code works but the Wizard opens first and you have to go through the step process in the Wizard before the second group of code is executed.
Can you help?