LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Excel2000: Opening *.csv through VBA and International Settings

Hi

A Firm leasing various IT devices has a web page, where customers can see
various info about their leased devices. There is a possibility to save this
info as a CSV-file.

When I open such CSV-file directly from Excel, then it's all OK - all data
is in right columns (there is 22 of them).
When I open the same CSV-file from VBA (I need to generate rental payments
table from it), then all data are messed up hopeless. The code which opens
the CSV-file is:
....
' Asking for source file
varFileTitle = "Open source file!"
varFileFilter = "Templates (*.CSV), *.CSV"
varSourceFile = Application.GetOpenFilename(Title:=varFileTitle,
FileFilter:=varFileFilter)
If varSourceFile = "False" Then
MsgBox ("Data import was stopped because no source file was
selected!")
Exit Sub
End If

' Opening source workbook
Workbooks.Open Filename:=varSourceFile
....

The reason is, that the CSV-file is using Estonian settings - semicolon is
used as data delimiter. But when CSV-file is opened from VBA, comma is used
as data delimiter instead. (In Estonian settings, comma is used as decimal
delimiter, and additionally in CSV-table in some columns with text data
[and in some column headers] the comma is simply used for punctuation).

How to force Excel VBA to use semicolons as delimiters when opening a
CSV-file. When there doesn't exist a way to do this, I have to open the
CSV-file as an ASCII file, and to use some heavy programming to read all
data into Excel - I hope I can avoid this.


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default settings when opening a text file with Excel David Fitzwater Excel Discussion (Misc queries) 1 August 12th 08 08:07 PM
Opening .csv file in Excel2003 vs Excel2000 Holmark Excel Discussion (Misc queries) 9 April 24th 07 07:43 PM
Solution to stopping IE opening excel workbooks without changing windows settings [email protected] Excel Discussion (Misc queries) 0 May 24th 06 11:05 AM
Settings are changed when opening workbook on a different computer J Excel Discussion (Misc queries) 1 March 31st 06 06:11 PM
Opening Excel after changing settings and add-ins swesterm Excel Discussion (Misc queries) 3 December 29th 04 06:54 PM


All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"