Skip to content

Instantly share code, notes, and snippets.

@ThatsJustCheesy
Created July 30, 2022 01:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThatsJustCheesy/2b504fea78068c098f64f9ec90fb7d1e to your computer and use it in GitHub Desktop.
Save ThatsJustCheesy/2b504fea78068c098f64f9ec90fb7d1e to your computer and use it in GitHub Desktop.
Make PowerPoint slides from plain text paragraphs
' This macro creates slides from plain text on your clipboard.
' Two consecutive line breaks begin a new slide.
' New slides will be duplicates of the selected slide,
' which must contain a single text box and nothing else.
'
' Usage:
' 1. Prepare plain text paragraphs of your slide content
' 2. Copy the text to your clipboard
' 3. Select a slide that contains a single text box with desired formatting
' 4. Run ParagraphsToSlides as a macro
' 5. Watch your slides be generated after the one you had selected
Sub ParagraphsToSlides()
Set initiallyActiveSlide = ActiveWindow.View.Slide
With initiallyActiveSlide.Duplicate
With .Shapes(1).TextFrame2.TextRange
.PasteSpecial msoClipboardFormatPlainText
clipboard_ = .Text
End With
.Delete
End With
initiallyActiveSlide.Select
' For a reason unbeknownst to mankind, *only* vbCr works here;
' vbNewLine should be preferred, and vbLf should at least *work*,
' but noooo, we don't get the luxury of sanity in VBA.
paragraphs_ = Split(clipboard_, vbCr & vbCr)
For Each paragraph_ In paragraphs_
With ActiveWindow.View.Slide.Duplicate
.Shapes(1).TextFrame2.TextRange.Text = paragraph_
End With
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment