Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Date and language

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mapsit - 04 Jan 2006 10:44 GMT
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?
Perry - 04 Jan 2006 18:09 GMT
> 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

> Format(Date, "d mmmm yyyy")
>
[quoted text clipped - 10 lines]
>
> Is something possible with a macro?
mapsit - 05 Jan 2006 08:33 GMT
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??

> Below VBA statement is the result of a recorded macro doing exactly what you
> asked ...
[quoted text clipped - 3 lines]
>         :=False, DateLanguage:=wdDutch, CalendarType:=wdCalendarWestern, _
>         InsertAsFullWidth:=False
Helmut Weber - 06 Jan 2006 03:12 GMT
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.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.