csv import from different locale?

E

Ethan Strauss

Hi,
I would like to be able to have computers with one region/locale setting
correctly import .csv files created with different locale settings.
Specifically, the files are created with US settings and are being read with
German settings, but it would be best if there was a general solution for all
settings.
My first thought was to write a macro with does the following

Save user's current settings in a variable
Change settings to US
Import file (open dialog etc)
Change setting back to original.
But, I can't find a way to alter the locale using VBA within Excel.
I have a semi working macro with imports the file using
Application.ActiveSheet.QueryTables.Add(Connection:=fileName,
Destination:=Range("$A$1")) and making sure that all rows are interpreted as
text, then replacing all periods with commas, then formatting everything as
numbers, but this has issues.
So, is it possible to change locale settings from within Excel VBA?
If not, any ideas how to deal with csv import locale issues?

Thanks!
Ethan
 
G

Gary''s Student

I think you original idea is better. Whether manually or via VBA using:

Data > Import External Data > Import Data...

should give you the ability to directly specify each field's regional
character, whether it is date format, separator format, etc.

Changing regional settings to match the data may not be safe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top