Help to manipulate/assign result CalculateAge to my ActiveDocument screen,
assign it toa DocProp or DocVariable
and a ContentControl
or the ActiveDocument screen at a bookmark please?
I can read result CalculateAge in a MsgBox fine.


Function Calculate(birthDate As Date) As Byte
Dim birthdayNotPassed As Boolean
birthdayNotPassed = CDate(Month(birthDate) & " / " & _
Day(birthDate) & " / " & _
Year(Now)) > Now
CalculateAge = Year(Now) - Year(birthDate) + birthdayNotPassed

End Function

Re: Date Function manipulate result by Helmut

Helmut
Wed May 14 07:42:28 PDT 2008

Hi Jen,

use "option explicit",
as CalculateAge is not declared in your code.

Maybe this helps:

Function Calculate(birthDate As Date) As String
Dim birthdayNotPassed As Boolean
birthdayNotPassed = CDate(Month(birthDate) & " / " & _
Day(birthDate) & " / " & _
Year(Now)) > Now
Calculate = CStr(Year(Now) - Year(birthDate) + birthdayNotPassed)
End Function

Sub Test561()
ActiveDocument.Variables("Age").Value = _
Calculate("06.11.49") ' watch out, german date format
MsgBox ActiveDocument.Variables("Age").Value
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Re: Date Function manipulate result by Jen

Jen
Wed May 14 23:44:28 PDT 2008

Thanks once again Helmut, I have Option Explicit. I was having trouble with
accessing the answer.

"Helmut Weber" <red.sys@t-online.de> wrote in message
news:tdul249nedgkh0i66a72upcv4ucortco5t@4ax.com...
> Hi Jen,
>
> use "option explicit",
> as CalculateAge is not declared in your code.
>
> Maybe this helps:
>
> Function Calculate(birthDate As Date) As String
> Dim birthdayNotPassed As Boolean
> birthdayNotPassed = CDate(Month(birthDate) & " / " & _
> Day(birthDate) & " / " & _
> Year(Now)) > Now
> Calculate = CStr(Year(Now) - Year(birthDate) + birthdayNotPassed)
> End Function
>
> Sub Test561()
> ActiveDocument.Variables("Age").Value = _
> Calculate("06.11.49") ' watch out, german date format
> MsgBox ActiveDocument.Variables("Age").Value
> End Sub
>
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP