Skip to content

Instantly share code, notes, and snippets.

@modellking
Last active January 18, 2021 16:33
Show Gist options
  • Save modellking/a1f267ee4c7f61156b1cb19acc6f8bc0 to your computer and use it in GitHub Desktop.
Save modellking/a1f267ee4c7f61156b1cb19acc6f8bc0 to your computer and use it in GitHub Desktop.
Powerpoint Uhr | Powerpoint Clock | VBA
Option Explicit
Private abortFlag As Boolean
Sub pause()
Dim start
start = Timer
Do While Timer < start + 0.1
DoEvents
Loop
End Sub
Sub MakeClock(oSH As Shape)
Dim clkFormat
clkFormat = oSH.TextFrame.TextRange.Text
abortFlag = False
Do Until abortFlag = True
On Error Resume Next
oSH.TextFrame.TextRange.Text = format((Now()), clkFormat)
pause
Loop
oSH.TextFrame.TextRange.Text = clkFormat
End Sub
Sub OnSlideShowPageChange(ByVal objWindow As SlideShowWindow)
abortFlag = True
End Sub
Sub OnSlideShowTerminate()
abortFlag = True
End Sub
How-to / Anleitung:
English:
Steps to insert Clocks:
1. Create a VBA Module
1.1 Add Developer ribbon
1.1.1 Right-click anywhere on a ribbon (the large top menupart)
1.1.2 Choose "Change Ribbons..." (or something similar to that)
1.1.3 On the right side find Developer and check the checkmark next to it
1.2 Navigate to Developer > Visual Basic
1.3 In the newly opened window on the left side in the Sub-Window "Project - VBA Project" you should find a fat Text saying "VBAProject (???.ppt?)"
1.4 Rightclick it and add a new Module via Add > Module.
2. Copy-Paste the Code from this Gist to the Editor on the right side.
3. Switch back to the Main Window of Powerpoint.
4. Save the Presentation as pptm (Powerpoint Macro enabled Presentation)
5. Create a Textfield for the Clock
5.1 Create a Textfield (Insert > Textfield)
5.2 Write in das Textfield the format the clock should have (e.g. hh:mm:ss for the normal 24h format. I believe some folks use h:mm:ss AM/PM that sould work, too)
Make sure Powerpoint doesn't "correct" this and makes the first H uppercase
5.3 Mark the Textfield itself and add the Macro via Insert > Action > Execute Macro (Dropdown: MakeClock)
6. Format the Text however you wish
To enable the clock during a presentation click on it.
Deutsch:
Schritte um die Uhr einzufügen:
1. Erstelle ein VBA Modul
1.1 Entwicklertools Ribbon hinzufügen
1.1.1 Rechtsklicke auf den freien Bereich in einem Ribbon (der große Teil vom Menü)
1.1.2 Wähle "Menüband anpassen..."
1.1.3 Setze auf der rechten Seite den Haken bei Entwicklertools
1.2 Gehe zu Entwickler Tools > Visual Basic
1.3 In dem neuen Fester auf der linken Seite im Unterfenster "Projekt - VBA Project" befindet sich ein fetter Schristzug "VBAProject (???.ppt?)"
1.4 Rechtsklicke darauf und füge mit Einfügen > Modul ein neues Modul hinzu.
2. Copy-Paste den Code aus dem Gist in den Editor rechts.
3. Wechsle in das Hauptfenster von Powerpoint.
4. Speichere die Präsentation als pptm (Powerpoint Präsentation mit Makros)
5. Erstelle ein Textfeld für die Uhr
5.1 Erstelle ein Textfeld (Einfügen > Textfeld)
5.2 Schreibe in das Textfeld das Format, dass die Uhrzeit haben soll (z.B. hh:mm:ss für das normale 24h Format)
Achte darauf, dass Powerpoint nicht die Großschreibung "korrigiert"
5.3 Markiere das Textfeld selbst und füge über Einfügen > Aktion > Makro ausführen (Dropdown: MakeClock) das Makro hinzu.
6. Formatiere den Text wie du willst
Zum verwenden in der Präsentation einfach das Textfeld anklicken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment