Reply
 
Thread Tools Display Modes
  #1   Report Post  
kathleen
 
Posts: n/a
Default convert time to hours in Word table

Trying to set up a timecard that calculates hours worked from time entered.
Thank you.
IN OUT Hours worked
9:00 am 5:30 pm h:m
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

The following will need a bit of a modification for hours entered in the way
you are doing it (It assumes that the hours are entered in 24hours clock
format and that we are not talking about someone working the graveyard
shift):

' a Macro to calculate the elapsed time for formfields with Date format of
HH:mm

' Macro created 16 May 1999 by Doug Robbins - Word MVP

'

Start = ActiveDocument.FormFields("Text1").Result

StartHour = Val(Left(Start, 2))

StartMinutes = Val(Right(Start, 2))

StartTimeMinutes = StartHour * 60 + StartMinutes

Finish = ActiveDocument.FormFields("Text2").Result

FinishHour = Val(Left(Finish, 2))

FinishMinutes = Val(Right(Finish, 2))

FinishTimeMinutes = FinishHour * 60 + FinishMinutes

ElapsedMinutes = FinishTimeMinutes - StartTimeMinutes

ElapsedHours = Int(ElapsedMinutes / 60)

ElapsedMinutes = ElapsedMinutes - ElapsedHours * 60

ActiveDocument.FormFields("Text3").Result = Str(ElapsedHours) & ":" &
Format(ElapsedMinutes, "00")


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"kathleen" wrote in message
...
Trying to set up a timecard that calculates hours worked from time
entered.
Thank you.
IN OUT Hours worked
9:00 am 5:30 pm h:m



  #3   Report Post  
Jezebel
 
Posts: n/a
Default

An alternative to Doug's answer is to embed an Excel table: then you can do
the time arithmetic directly.


"kathleen" wrote in message
...
Trying to set up a timecard that calculates hours worked from time
entered.
Thank you.
IN OUT Hours worked
9:00 am 5:30 pm h:m



Reply
Thread Tools
Display Modes

Posting Rules

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Word 2003 documents to WordPerfect formate Carol Microsoft Word Help 6 March 9th 06 07:11 AM
Reveal Codes BAW Microsoft Word Help 2 June 7th 05 03:38 PM
is word perfect compatible with office word? Noreen Microsoft Word Help 1 May 11th 05 11:17 PM
Continuous breaks convert to next page breaks Jennifer Hunt Microsoft Word Help 2 December 30th 04 05:45 PM
Table headers Sam Hobbs New Users 12 December 20th 04 07:18 PM


All times are GMT +1. The time now is 01:24 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"