Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change language to French in VBA

Posted on 2004-10-27
13
Medium Priority
?
3,047 Views
Last Modified: 2007-12-19
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 :)



0
Comment
Question by:Joanne M. Orzech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 4
  • +1
13 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 1200 total points
ID: 12428077
You have to change the Language in Windows to French(Canadian)

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

Author Comment

by:Joanne M. Orzech
ID: 12428152
Thanks Erick but is there any way to do that with VBA in Word?
0
 
LVL 48

Assisted Solution

by:Mikal613
Mikal613 earned 400 total points
ID: 12428297
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 48

Expert Comment

by:Mikal613
ID: 12428333
0
 
LVL 37

Author Comment

by:Joanne M. Orzech
ID: 12428901
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
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 400 total points
ID: 12429409
Why don't you create a small function that will return the month name in french independently of Windows?
0
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 1200 total points
ID: 12429474
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
 
LVL 32

Assisted Solution

by:Erick37
Erick37 earned 1200 total points
ID: 12429589
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
 
LVL 37

Author Comment

by:Joanne M. Orzech
ID: 12429692
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
 
LVL 32

Expert Comment

by:Erick37
ID: 12429782
Thanks for reminding me!  Just in time :}
0
 
LVL 37

Author Comment

by:Joanne M. Orzech
ID: 12472537
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question