dbTalk Databases Forums  

Exporting Time Data to EXCEL

comp.database.ms-access comp.database.ms-access


Discuss Exporting Time Data to EXCEL in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Laurie
 
Posts: n/a

Default Exporting Time Data to EXCEL - 12-18-2003 , 08:04 PM






Hi
Using Dev Ashish's code from a previous email I have been able to
successfully export output from a query to an EXCEL spreadsheet
however the all time fields are appearings as dates ie) 0/01/1900
12:25:00 PM
If I manually format the column on the spreadsheet to a time type all
is well but I wondering if there is an automatic way to do this, maybe
inside Dev Ashish's Automate VBA code.

Thanks
Laurie

Reply With Quote
  #2  
Old   
Ray
 
Posts: n/a

Default Re: Exporting Time Data to EXCEL - 12-23-2003 , 07:59 AM






lesparke (AT) austarnet (DOT) com.au (Laurie) wrote in message news:<fef26cb7.0312181804.66af2fd3 (AT) posting (DOT) google.com>...
Quote:
Hi
Using Dev Ashish's code from a previous email I have been able to
successfully export output from a query to an EXCEL spreadsheet
however the all time fields are appearings as dates ie) 0/01/1900
12:25:00 PM
If I manually format the column on the spreadsheet to a time type all
is well but I wondering if there is an automatic way to do this, maybe
inside Dev Ashish's Automate VBA code.

Thanks
Laurie
Hello Laurie,

I ran tests to see if I could produce the same results
you state above and I did. At this time, I'm still working
on it. But, as a stop gap measure, I did find that if I
opened the Excel file and highlighted the offending column,
I could change the column property to Time and it changed
the data accordingly.

Perhaps you could try and see if this works in the mean time.

Another thing you can do temporarily is to make your time field
a text field with an input mask set to "Long Time".

O'well, keep on trying.

Regards,

Ray


Reply With Quote
  #3  
Old   
Laurie
 
Posts: n/a

Default Re: Exporting Time Data to EXCEL - 12-27-2003 , 11:01 PM



raycait (AT) excite (DOT) com (Ray) wrote in message news:<20ba9f4a.0312230559.67b759b1 (AT) posting (DOT) google.com>...
Quote:
lesparke (AT) austarnet (DOT) com.au (Laurie) wrote in message news:<fef26cb7.0312181804.66af2fd3 (AT) posting (DOT) google.com>...
Hi
Using Dev Ashish's code from a previous email I have been able to
successfully export output from a query to an EXCEL spreadsheet
however the all time fields are appearings as dates ie) 0/01/1900
12:25:00 PM
If I manually format the column on the spreadsheet to a time type all
is well but I wondering if there is an automatic way to do this, maybe
inside Dev Ashish's Automate VBA code.

Thanks
Laurie

Hello Laurie,

I ran tests to see if I could produce the same results
you state above and I did. At this time, I'm still working
on it. But, as a stop gap measure, I did find that if I
opened the Excel file and highlighted the offending column,
I could change the column property to Time and it changed
the data accordingly.

Perhaps you could try and see if this works in the mean time.

Another thing you can do temporarily is to make your time field
a text field with an input mask set to "Long Time".

O'well, keep on trying.

Regards,

Ray
Hi Ray
Thanks for replying to the post.
In the end I used the Range option called "NumberFormat". The code
also applies a "classic" format to the result.

----example only----
Private Sub delimitbatchExport_Click()
On Error GoTo Err_delimitbatchExport_Click

Dim rs As Recordset
Dim intMaxCol As Integer
Dim intMaxRow As Integer
Dim objXL As Excel.Application
Dim objWkb As Workbook
Dim objSht As Worksheet
Dim SQLstm As String

SQLstm = "A select query"
Set rs = CurrentDb.OpenRecordset(SQLstm)
intMaxCol = rs.Fields.count
If rs.RecordCount > 0 Then
rs.MoveLast: rs.MoveFirst
intMaxRow = rs.RecordCount
intMaxRow = intMaxRow + 1
Set objXL = New Excel.Application
With objXL
.Visible = True
Set objWkb = .Workbooks.Add
Set objSht = objWkb.Worksheets(1)
With objSht
.Cells(1, 1).Value = "Registration"
.Cells(1, 2).Value = "Date"
.Cells(1, 3).Value = "Time of Flight"
.Cells(1, 4).Value = "Time Noted"

.Range(.Cells(2, 1), .Cells(intMaxRow,
intMaxCol)).CopyFromRecordset rs
.Range(.Cells(2, "C"), .Cells(intMaxRow, "C")).NumberFormat =
"[hh]:mm"
.Range(.Cells(2, "D"), .Cells(intMaxRow, "D")).NumberFormat =
"[hh]:mm"
.Range(.Cells(2, "E"), .Cells(intMaxRow, "E")).NumberFormat =
"general"
.Range(.Cells(1, 1), .Cells(intMaxRow, intMaxCol)).AutoFormat
xlRangeAutoFormatClassic1
.Range(.Cells(1, 1), .Cells(1, intMaxCol)).Font.Bold = True

End With
End With
End If
Exit_delimitbatchExport_Click:
Exit Sub

Err_delimitbatchExport_Click:
MsgBox Err.Description
Resume Exit_delimitbatchExport_Click
End Sub


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.