Bonjour,
Dans son message, < Lena > écrivait :
In this message, < Lena > wrote:
|| Hey all, depending on what language they chose I want the date to be
displayed in French. Why
|| isn't this code working?
||
|| If Me.optFrench.Value = True Then
|| Options.MonthNames = wdMonthNamesFrench
|| Else
|| Options.MonthNames = wdMonthNamesEnglish
|| End If
|| Me.txtDate.Value = MonthName(Month(Date)) & " " & Day(Date) _
|| & ", " & Year(Date)
||
"Options.MonthNames" refers to Word' options, which, I believe, have no
bearing to what is going on in a userform.Also, I believe that "MonthName is
supposed to be used just to return a month format, yet you are using it for
a full date format...
Look up Format in the VBA help... But I do not think that one of the
parameters is "language".
As far as I can tell with my limited knowledge regarding date, is that the
date language is actually controlled by either the system default, which you
do not want to mess with from VBA, unless there is an esay way of doing this
I am unaware of, or Word's dictionary language for a particular range of
text. If you insert a DATE or TIME field and assign French, the date will be
displayed in French, now change the language for that field from French to
English and update the field, you will see the date change language, but not
the format.... You will end up with and English language date with a French
format as in: 12 April 2004.
I have the following "trick" to set the current date's language in a user
form:
'_______________________________________
Private Sub CommandButton1_Click()
Me.Hide
Unload Me
End Sub
'_______________________________________
'_______________________________________
Private Sub optEnglish_Click()
InsertCurDate "MMMM d, yyyy", 4105
End Sub
'_______________________________________
'_______________________________________
Private Sub optFrench_Click()
InsertCurDate "d MMMM yyyy", 3084
End Sub
'_______________________________________
'_______________________________________
Function InsertCurDate(DateForm As String, DateLang As Long)
'1036 = French
'3084 = FrenchCanadian
'4105 = EnglishCanadian
'2057 = EnglishUK
Dim MyRange As Range
Selection.Collapse
Set MyRange = Selection.Range
MyRange.InsertParagraphAfter
MyRange.Collapse
MyRange.InsertParagraphBefore
MyRange.Collapse wdCollapseEnd
MyRange.InsertDateTime DateTimeFormat:=DateForm, InsertAsField:= _
False, DateLanguage:=DateLang, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Set MyRange = MyRange.Paragraphs(1).Range
MyRange.MoveEnd wdCharacter, -1
Me.txtDate.Value = MyRange.Text
ActiveDocument.Undo 3
Set MyRange = Nothing
End Function
'_______________________________________
Or you could create an invisible temporary document and dismiss it at the
end, this way you are guaranteed not to mess with the actual document.
Good luck!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org