Opening Files


Posted by James Wiltshire on October 12, 2000 8:29 AM

Hello. I`m trying to open multiple .txt files using "Application.Dialogs(xlDialogOpen).Show". The problem is that when i click on the OPEN button i have to keep on having to go through the "text import wizard". Is there any way to open the files without the wizard popping up.

Thanks

James

Posted by Ben O. on October 12, 2000 9:18 AM

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

Posted by Ben O. on October 12, 2000 9:20 AM

Whoops, I see that you need to open multiple text files. My code will only work with one. Sorry (n/t)

Posted by DBlowers on October 12, 2000 11:49 AM

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

Posted by James on October 13, 2000 2:23 AM

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



Posted by Mike on October 15, 2000 12:47 AM

multiple text files.

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