Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Open csv file with all values as text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bony_tony - 19 Sep 2007 17:22 GMT
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
Tom Ogilvy - 19 Sep 2007 18:02 GMT
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.  

Signature

Regards,
Tom Ogilvy

> Hi,
> When excel opens my csv file, the numbers in it are automatically
[quoted text clipped - 9 lines]
> Cheers
> Tony
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.