Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 76
Default Open csv file with all values as text

Hi,
When excel opens my csv file, the numbers in it are automatically
changed to actual numbers, when I want them displayed as text/strings.

The problem with this is that, i.e my string "00500" is changed to the
value 500 when the file is opened, and will remain as 500 when the
file is saved again.

Does someone have some code which will prompt the user to select a csv
file, then open the file with all values as text/strings??

Cheers
Tony

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Open csv file with all values as text

Change the extension to .txt instead of .csv and then open it in excel. Walk
through the text import wizard with the macro recorder turn on.

In the last dialog indicate which columns should be treated as text.

complete the import and turn off the macro recorder.

In your code, add code at the top to copy the file and rename the copy with
a .txt extension. Then open that (and delete it later if necessary).


Even with recorded code, it you open a file with a .csv extention, your
settings will be ignored.

--
Regards,
Tom Ogilvy


"bony_tony" wrote:

Hi,
When excel opens my csv file, the numbers in it are automatically
changed to actual numbers, when I want them displayed as text/strings.

The problem with this is that, i.e my string "00500" is changed to the
value 500 when the file is opened, and will remain as 500 when the
file is saved again.

Does someone have some code which will prompt the user to select a csv
file, then open the file with all values as text/strings??

Cheers
Tony


Reply
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
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
External link only works for numbers -- for text values, #N/A is displayed unless linked file is open Sven Filter Links and Linking in Excel 1 February 22nd 05 08:10 AM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 10:38 PM.

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

About Us

"It's about Microsoft Excel"