0

I need to make two presentations with the same slides, backgrounds, and everything except for the text: one in German and one in English. Therefore I have two separate presentations which I must always simultaneously update, otherwise one language version will be outdated and I often forget what I changed.

I have made a custom show with all of the slides copied into one PowerPoint presentation and that works fairly well, but I still must change two of the same slides each time that I make an edit to one language.

Therefore, I'm trying to write a macro that will recognize all textboxes within the presentation with German text in them and hide them during the show, and vice versa. Then, each of the macros would be linked to a hyperlinked box on the title slide called 'English' or 'German' which, when clicked, would hide the textboxes in the other languages while also leaving all pictures and formatting the same. Ideally, the macro would hide all boxes in one language and make all the boxes in the other language visible again within the same step, so that the presentation is always usable and I don't have a user who opens a PPT with 'no text boxes' because they would all be hidden...

In order to achieve this I have two text boxes containing the text in both languages on the same slide, that's why I'd like to hide the textboxes.

I am able to get all text boxes hidden but not text boxes in a specific language (aka, all boxes regardless of their editing language will get hidden but not any specific ones).

PS - text boxes do not NEED to be referenced here... it could just refer to a shape. I was trying to avoid, that Pictures would be hidden and thought text boxes would be the best way to reference what I wanted.

Is there a better way?

I don't really know how to reference a language in VBA, I found this website by accident and thought someone might have a quick trick to help me out with this issue. The code I have which will blend out textboxes but not blend out specific language-boxes is as follows:

Sub GermanTextBoxFinder()
    Dim SlideToCheck As Slide
    Dim ShapeIndex As Integer
      ' Visit each slide
    For Each SlideToCheck In ActivePresentation.Slides
      ' On each slide, count down through the shapes
    For ShapeIndex = SlideToCheck.Shapes.Count To 1 Step -1
      ' If the shape IS a text box and DOES have German text
    If SlideToCheck.Shapes(ShapeIndex).Type = msoTextBox And _
    MsoLanguageID.msoLanguageIDGerman _
Then
    ' Toggle visibility of German Textboxes
    SlideToCheck.Shapes(ShapeIndex).Visible = msoFalse
End If
Next
Next

End Sub
vandey08
  • 1
  • 2

2 Answers2

0

Why don't you name the shapes with German text something that identifies them? E.g. use the prefix "txtGER" for the texts in German and "txtENG" for the ones in English. Then you could use something like the following:

If SlideToCheck.Shapes(ShapeIndex).Type = msoTextBox And _
    Left(SlideToCheck.Shapes(ShapeIndex).Name, 6) = "txtGER" Then
    ' Toggle visibility of German Textboxes
    SlideToCheck.Shapes(ShapeIndex).Visible = msoFalse
Else
    SlideToCheck.Shapes(ShapeIndex).Visible = msoTrue
End If

(Please see this q+a for information on how to rename the shapes).

Community
  • 1
  • 1
Olle Sjögren
  • 5,315
  • 3
  • 31
  • 51
0

This will hide text boxes/shapes with text that contain either English or French. You can modify HideFrench to hide German instead ... Intellisense will provide the correct constants.

Sub HideEnglish()
    Dim oSl As Slide
    Dim oSh As Shape

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    If oSh.TextFrame.TextRange.LanguageID = msoLanguageIDEnglishUS Then
                        oSh.Visible = False
                    Else
                        oSh.Visible = True
                    End If

                End If
            End If
        Next
    Next
End Sub

Sub HideFrench()
    Dim oSl As Slide
    Dim oSh As Shape

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    If oSh.TextFrame.TextRange.LanguageID = msoLanguageIDFrench Then
                        oSh.Visible = False
                    Else
                        oSh.Visible = True
                    End If

                End If
            End If
        Next
    Next
End Sub
Steve Rindsberg
  • 14,442
  • 1
  • 29
  • 34
  • Thanks, Steve! This works perfectly. Something I didn't think about earlier, though, is that, when I make an action button on the title slide (i.e. 'German' (link to hide English macro)) with a hyperlink to run the macro, it will also hide that Action button, meaning a user can't click it again to unhide the textboxes without running the macro another way. How would I write an exception to leave out the title slide from being hidden? Or, specifically reference the Action box to not be hidden? – vandey08 Jan 18 '17 at 08:22
  • Off top of head, I'd have the HideEnglish subroutine also change the text of the Action button to "However you say HIDE GERMAN auf Deutsch" and have the HideGerman subroutine change it to "Hide English" – Steve Rindsberg Jan 18 '17 at 16:27