Time Calculation

  • Thread starter Thread starter d
  • Start date Start date
D

d

Is it possible to format the result of a calculation
field? for example I have a form with fields that I total.
I would like to format that field as HH:MM
 
This does not exactly answer your question, but it will show you how you
will have to go about it:

' a Macro to calculate the elapsed time for formfields with Date format of
HH:mm
' Macro created 16 May 1999 by Doug Robbins
'
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")


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
Back
Top