ab123456
Chemical
- Mar 18, 2003
- 58
I am trying to open a new file within excel when running a macro. The file to open will have a different name each time so i require the user to input the filename. The file will always be a comma separated text file. I need the file to open in excel without having to go through the text import wizard each time.
I have got the code to automatically open the CSV if i know the filename but am having problems in allowing the user to select the file.
I would like to use the standard open file dialog box to do this. I can show the dialog using the code
Application.Dialogs(xlDialogOpen).Show
and this works fine except that once the user selects the file excel tries to open it and launches the text import wizard.
Is there a way that i can use the standard dialog to return the filename but not open it? I can then use the code below to avoid the text import wizard running
Workbooks.OpenText Filename:= name_and_path_of_file, StartRow:=1, DataType:=xlDelimited, comma:=True
I have got the code to automatically open the CSV if i know the filename but am having problems in allowing the user to select the file.
I would like to use the standard open file dialog box to do this. I can show the dialog using the code
Application.Dialogs(xlDialogOpen).Show
and this works fine except that once the user selects the file excel tries to open it and launches the text import wizard.
Is there a way that i can use the standard dialog to return the filename but not open it? I can then use the code below to avoid the text import wizard running
Workbooks.OpenText Filename:= name_and_path_of_file, StartRow:=1, DataType:=xlDelimited, comma:=True