Powerpoint macro to reveal

I think that everyone knows PowerPoint. However, reveal.js is a simple js+css + html to make presentation. I like it – and it is easy to put on any presentation.

Remembering my VB roots , I have created a simple PowerPoint macro to save presentation as reveal. It takes advantage that PowerPoint could save the slides as JPG.

Some sample code is here:

 

Sub ToReveal()
‘where to save the reveal
Dim rootFolder As String
rootFolder = "D:\"

Dim sld As slide, shp As Shape
Dim textSlide As String
Dim p As Presentation
Set p = ActivePresentation
Dim name As String
name = p.name
If (InStr(1, p.name, ".") > 1) Then
name = Mid(name, 1, InStr(1, p.name, ".") – 1)
End If
Dim NameFolder As String
NameFolder = rootFolder + name + "_reveal"

ActivePresentation.SaveCopyAs NameFolder, ppSaveAsJPG
Dim Sections As String, i As Integer, max As Integer
max = p.Slides.Count

For i = 1 To max
Sections = Sections + vbCrLf
Sections = Sections + "<section>"
Sections = Sections + "<img src=’Slide" & i & ".jpg’>"
Sections = Sections + "</section>"

Next i
Dim str As String
str = OriginalReveal()
str = Replace(str, "#PPTName#", p.name)
str = Replace(str, "#section#", Sections)

Dim fileName As String, textRow As String, fileNo As Integer
fileName = NameFolder + "\index.html"
fileNo = FreeFile ‘Get first free file number

Open fileName For Output As #fileNo
Print #fileNo, str
Close #fileNo

End Sub

The full source code is on https://github.com/ignatandrei/ppt2reveal/tree/master

Press ALT+F11 , paste code and enjoy!