I'm trying to write an Excel macro using VBA to automate importing CSV text into a spreadsheet but I've never done it before. I need to make sure that the Text Import Wizard that comes up is run through the same way each time. The steps I need to take are:
- Open a file, using an open file dialog
- Set type to Delimited
- Set Delimiter to comma
- Set all columns to be imported as Text
- Auto fit all columns
I can't seem to wade through the documentation that shows how to do these things like open files. Even being able to start there would be helpful.
I ended up making some tweaks to the function before putting it into use.
Thanks to the above guys for getting me going.
The code below will allow a user to browse for a csv file.
It will then :
The .opentext code needs to be updated depending on the number of columns in the source data.