Change language to French in VBA

I've created a template in English.  Now I need to create an identical one in French (Canadian).  How do I change the language in the VB script to show - for example - the dates in French?

This is the code I'm using and even though I set the default language in the template to French Canadian, the date October shows up rather than Octobre.

   frmXXX.TextBox1.Text = "Le " & Format(VBA.Date, "dd Mmmm, yyyy")

As always, many thanks in advance experts :)



LVL 37
Joanne M. OrzechManager, Document Services CenterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
You have to change the Language in Windows to French(Canadian)

Control Panel->Regional and Language Options->[Regional Options]
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
Thanks Erick but is there any way to do that with VBA in Word?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Joanne M. OrzechManager, Document Services CenterAuthor Commented:
So write to the registry and then do I change it back?  It's for a high ranking public official and I want to get it right.  Many thanks for your responses.
0
Éric MoreauSenior .Net ConsultantCommented:
Why don't you create a small function that will return the month name in french independently of Windows?
0
Erick37Commented:
Just what I was going to suggest...

Just hardcode the months so as to not rely on any system or locale settings:

Option Explicit

Dim Months(12) As String


Private Sub CommandButton1_Click()

TextBox1.Text = "Le " & _
                Format(VBA.Date, "dd ") & _
                Months(DatePart("M", VBA.Date)) & _
                Format(VBA.Date, ", yyyy")

End Sub



Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()
   
    Months(1) = "Janvier"
    Months(2) = "Février"
    Months(3) = "Mars"
    Months(4) = "Avril"
    Months(5) = "Mai"
    Months(6) = "Juin"
    Months(7) = "Juillet"
    Months(8) = "Août"
    Months(9) = "Septembre"
    Months(10) = "Octobre"
    Months(11) = "Novembre"
    Months(12) = "Décembre"
   
End Sub
0
Erick37Commented:
Or simply

Option Explicit

Private Sub CommandButton1_Click()

    TextBox1.Text = FrenchDate(VBA.Date)

End Sub


Private Function FrenchDate(dtDate As Date) As String
    Dim sMonths() As String
    Dim sData As String
    sData = ".Janvier.Février.Mars.Avril.Mai.Juin.Juillet.Août.Septembre.Octobre.Novembre.Décembre"
    sMonths = Split(sData, ".")
    FrenchDate = Format(dtDate, "dd ") & _
                sMonths(DatePart("M", dtDate)) & _
                Format(dtDate, ", yyyy")
End Function
0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
Very cool!  I will try it later and get back probably tomorrow....got to watch the lunar eclipse right now !  Blood red full moon!  Very rare :)  And it's almost Halloween too!

Thanks much!!
0
Erick37Commented:
Thanks for reminding me!  Just in time :}
0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
Thanks all for your comments and suggestions.  Everything in the template was working great as I said, except when I used the command:

    frmLtr.TextBox.Text = Format(VBA.Date, "mmmm d, yyyy")

It still put the month in as English, even though I had changed the settings in Control Panel, and set the default language to French.

So I ended up doing this:

    Selection.TypeText Text:="Le "
    Selection.InsertDateTime DateTimeFormat:="d MMMM yyyy", InsertAsField:= _
        False, DateLanguage:=wdFrench(Canada), CalendarType:=wdCalendarWestern, _
        InsertAsFullWidth:=False

I appreciate all your assistance and am sure I'll be back for more.

Best regards to all.
JOrzech
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.