Date and language

M

mapsit

Format(Date, "d mmmm yyyy")

wil result in 4 januari 2006 (dutch language)
how can i get the output into a different language?

for example
4 Januar 2006 (German)
or
4 January 2006 (Englisch)

When i manual want to do it, (insert -> date/time) i can choose a
language.

Is something possible with a macro?
 
P

Perry

When i manual want to do it, (insert -> date/time) i can choose a
language.

Is something possible with a macro?

Yes.

Below VBA statement is the result of a recorded macro doing exactly what you
asked ...

Selection.InsertDateTime DateTimeFormat:="dddd d MMMM yyyy",
InsertAsField _
:=False, DateLanguage:=wdDutch, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False

Krgrds,
Perry
 
M

mapsit

What's live easy....

Ok, but thats half wat i want. I don't want that date into my document,
but i want the date into a variable for example MyDate = ......
With a if then statement i want to define different values (and
different datelangauges) to MyDate.
Is this possible??
 
H

Helmut Weber

Hi,

I guess you have to insert the language specific date
somewhere in your doc or in other one, if you like,
and read what was inserted into a variable.

Like:

Sub test09987()
Dim sDat As String
Dim rTmp As Range
Set rTmp = ActiveDocument.Range
rTmp.InsertAfter vbCrLf
' create a new paragraph at the end of the doc
Set rTmp = rTmp.Paragraphs.Last.Range
' set rTmp to be this paragraph's range
rTmp.InsertDateTime DateTimeFormat:="dddd d MMMM yyyy", _
InsertAsField:=False, DateLanguage:=wdDutch, _
CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
sDat = rTmp.Text
' assign the text of that range to a variable
sDat = Left(sDat, Len(sDat) - 1)
' cut off the paragraph mark
MsgBox "[" & sDat & "]" ' for testing
rTmp.Delete
' delete the created paragraph
End Sub

If that's alright and you need a little help
on creating a dialog or so for choosing a language,
let us know.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top