You could put in some code to let Excel know what settings to use when importing the data. When I used "Application.Dialogs(xlDialogOpen).Show", the Text Import Wizard still appeared, but with "Application.GetOpenFilename", it bypassed the wizard.
Sub Macro1()
Workbooks.OpenText Filename:=Application.GetOpenFilename, Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1))
End Sub
-Ben
Whoops, I see that you need to open multiple text files. My code will only work with one. Sorry (n/t)
Re: Whoops, I see that you need to open multiple text files. My code will only work with one. Sorry (n/t)
Yes, there is,
DisplayAlerts=False
Be sure to
DisplayAlerts=True
after you are finished opening the files
-d
Re: Whoops, I see that you need to open multiple text files. My code will only work with one. Sorry (n/t)
Sub Macro1()
Application.DisplayAlerts = False
Application.Dialogs(xlDialogOpen).Show
Application.DisplayAlerts = True
End Sub
is this the correct place to put the displayalerts ?
James
I used a listbox to hold the selected files from Application.GetOpenFilename then used a for next loop for the listbox.count to open each of the txt files. My only problem is I cannot get it to work with Application.GetOpenFilename and selecting multiple files. I have a dialog box that has two cmdbut's: [add files] and [done with files]. they can go select the files using Application.GetOpenFilename one by one, then go to done with files and it runs thru the loop. If you figure out how to use multiple files to fill a listbox with Application.GetOpenFilename, please let me know!! hope that helps