vbapowerpointoffice-2007

How can I get a list of supported languages, map language IDs to names, and show language selector in PowerPoint presentations?


I am working on a "fix language in entire document" script with a proper GUI for language selection. However, I am unable to programmatically generate a list of all languages PowerPoint knows including the language names in the user's own language.

For this reason, I am looking for the following:

In Word, I could use the Language object, but that doesn't seem to exist in PowerPoint.

Alternatively, a way to show the user a dialog that will set the DefaultLanguageID would be sufficient (I could grab the desired language from there).

I couldn't even find a way to set that via the GUI. Showing a similar language selector and getting the result would obviously do the job, too.

The target platform is Office 2007.


Solution

  • What about using Word Languages collection which contains Language objects in PowerPoint macro? So you can get the Language-Name for the MsoLanguageID Enum values. Here you can find the languages Office is available in.

    ' Powerpoint code
    ' add reference to word lib.
        
        Public Sub test()
            Dim wordAppliacation As New Word.Application
            wordAppliacation.Visible = False
            
            On Error Resume Next
            
            Dim languageId As MsoLanguageID
            For languageId = msoLanguageIDArabic To msoLanguageIDSpanishPuertoRico
                Debug.Print languageId & ", " & wordAppliacation.Languages(languageId).Name & ", " & wordAppliacation.Languages(languageId).NameLocal
            Next languageId
            
            On Error GoTo 0
            
            wordAppliacation.Quit
            Set wordAppliacation = Nothing
        
        End Sub
    

    Or maybe just like this in PowerPoint 2016:

        Dim lng As Word.language
        Dim lid As Long
        
        For Each lng In wordAppliacation.Languages
            lid = lng.id
            Debug.Print lid & ", " & wordAppliacation.Languages(lid).Name & ", " & wordAppliacation.Languages(lid).NameLocal
        Next lng