Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trouble with OpenText() and Date/Time Values

Hello,

I want to import a CSV into an Excel worksheet. Each line of the
CSV file contains three integers and a date/time value in
mm/dd/yyyy hh:mm:ss format. Here are a few lines from the actual
CSV file:

1,101,26,3/19/2006 13:02:00
2,102,27,3/19/2006 13:02:10
3,103,28,3/19/2006 13:02:20
4,104,29,3/19/2006 13:02:30
5,105,30,3/19/2006 13:02:40
6,106,31,3/19/2006 13:02:50

If I open this file using the normal File-Open command,
everything works fine. However, when I try to open it using the
OpenText() method, the "seconds" part of the time values gets
dropped and all the time values end up the same in the worksheet
(13:02:00 for the data in the example above).

(I know that you have to change the cell formatting from the
default in order to see the "seconds" part of the date/time
values.)

The code that I'm using follows. What can I do to get OpenText()
to correctly read the "seconds" part of my time values?

Thanks,

-- Russ Cooper

------------------------------------------------------------------

On Error GoTo RawDataProblem
Workbooks.OpenText (RawFilename.Text) ' Raw data - temp workbook
On Error GoTo 0
ActiveSheet.UsedRange.Select ' Select raw data
Selection.Copy ' Copy raw data to clipboard
ActiveWorkbook.Close ' Close the temporary workbook

On Error Resume Next ' Error handling off for now
Set TargetSheet = Worksheets("Raw") ' Try to access Raw worksheet
On Error GoTo 0 ' Resume normal error handling
If Not TargetSheet Is Nothing Then ' If Raw worksheet exists,
Worksheets("Raw").Delete ' delete it
End If ' End "Raw worksheet exists"

Set NewSheet = Worksheets.Add ' Make a new worksheet
NewSheet.name = "Raw"
Worksheets("Raw").Range("A1").Select ' Paste raw data here
Worksheets("Raw").Paste ' Do the pasting

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
Converting date/time serial values to cumulative time totals... Kevin B Excel Discussion (Misc queries) 4 October 18th 07 05:05 PM
Calculations from date and time values kp Excel Worksheet Functions 7 November 27th 05 08:07 PM
Problem with OpenText in Excel 2000 (date format) sorin Excel Programming 1 September 13th 05 06:03 PM
Date format is not correct when using OpenText in Excel 2000 Mats L Excel Programming 1 September 14th 04 01:15 AM
After OpenText all pastes from external apps use format from OpenText Jim[_31_] Excel Programming 1 November 8th 03 02:17 AM


All times are GMT +1. The time now is 10:03 AM.

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"