ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a .csv file thru a macro (https://www.excelbanter.com/excel-programming/409420-opening-csv-file-thru-macro.html)

[email protected]

Opening a .csv file thru a macro
 
I have a macro that starts by displaying the "open file" window so the
user can select a .csv file to be opened and then processed. It works
great in the US. I now have a colleague in Argentina that is
running this macro, and when the csv file is opened all the data is
just stuffed into column A. Normally, it should be spread across
cols. A thru W. To fix this I'd like to be able to either: 1.
tell my Argentinian colleague how to alter her default Excel settings
so that Excel will properly open the csv files on her PC, or, 2.
change the way the macro works so that it automatically displays the
"file open wizard" after she has selected the .csv that is to be
opened. Any Suggestions for how to do either of these options?

Thanks.

cht13er

Opening a .csv file thru a macro
 
On Apr 15, 2:22*pm, wrote:
I have a macro that starts by displaying the "open file" window so the
user can select a .csv file to be opened and then processed. It works
great in the US. * *I now have a colleague in Argentina that is
running this macro, and when the csv file is opened all the data is
just stuffed into column A. * Normally, *it should be spread across
cols. A thru W. * *To fix this I'd like to be able to either: *1.
tell my Argentinian colleague how to alter her default Excel settings
so that Excel will properly open the csv files on her PC, *or, *2.
change the way the macro works so that it automatically displays the
"file open wizard" after she has selected the .csv that is to be
opened. * * Any Suggestions for how to do either of these options?

Thanks.


What are the differences in the settings?

[email protected]

Opening a .csv file thru a macro
 
On Apr 15, 2:22 pm, wrote:
I have a macro that starts by displaying the "open file" window so the
user can select a .csv file to be opened and then processed. It works
great in the US. I now have a colleague in Argentina that is
running this macro, and when the csv file is opened all the data is
just stuffed into column A. Normally, it should be spread across
cols. A thru W. To fix this I'd like to be able to either: 1.
tell my Argentinian colleague how to alter her default Excel settings
so that Excel will properly open the csv files on her PC, or, 2.
change the way the macro works so that it automatically displays the
"file open wizard" after she has selected the .csv that is to be
opened. Any Suggestions for how to do either of these options?

Thanks.


What code are you using to open the file?

This method seems to work for me when opening comma delimited text
files, but I'm not sure if language settings might break it:
Workbooks.OpenText Filename:=Path & "\MyTextFile.ext", _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=True _
, Space:=False, Other:=True, OtherChar:="="
Set WbMyFile = ActiveWorkbook

[email protected]

Opening a .csv file thru a macro
 
On Apr 15, 2:39 pm, wrote:
On Apr 15, 2:22 pm, wrote:

I have a macro that starts by displaying the "open file" window so the
user can select a .csv file to be opened and then processed. It works
great in the US. I now have a colleague in Argentina that is
running this macro, and when the csv file is opened all the data is
just stuffed into column A. Normally, it should be spread across
cols. A thru W. To fix this I'd like to be able to either: 1.
tell my Argentinian colleague how to alter her default Excel settings
so that Excel will properly open the csv files on her PC, or, 2.
change the way the macro works so that it automatically displays the
"file open wizard" after she has selected the .csv that is to be
opened. Any Suggestions for how to do either of these options?


Thanks.


What code are you using to open the file?

This method seems to work for me when opening comma delimited text
files, but I'm not sure if language settings might break it:
Workbooks.OpenText Filename:=Path & "\MyTextFile.ext", _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=True _
, Space:=False, Other:=True, OtherChar:="="
Set WbMyFile = ActiveWorkbook



Here is the current code to open the .csv file

Dim FName As Variant
FName = Application.GetOpenFilename("Excel Files (*.csv),*.csv")


All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com