PDA

View Full Version : [SOLVED:] PPT macro needed to export all text (incl. shapes) to a Word file



isabelle r
10-11-2016, 02:53 AM
Hello,


I have a PPT file in which text is stored partially in normal text boxes and partially in shapes (these shapes are displayed using animations, and are used to simulate windows which open when the user clicks a button).


I've tried a number of ways to export text, but it usually only exports the text in the slides without the text in the shapes. :crying:


I'd need a macro to export all the text in the PPT, including shapes, to a Word document, keeping basic formatting (bold, italic), and labelling the text: for each slide, its number, and for each shape the name of the shape.


For example, if slide number 1 contains the text "Hello world" and a box named Rectangle1 with the text "Hi there", the exported file should look like this:
===
SLIDE 1


Hello world


Rectangle1: Hi there
===
... and so on for each slide.


I know I'm asking a lot, but is this doable at all?


Thank you in advance,

John Wilson
10-11-2016, 03:48 AM
The last example on this page will do pretty well what you need. It doesn't keep formats though.

http://www.pptalchemy.co.uk/PPT2WORD.html

isabelle r
10-11-2016, 07:44 AM
Thanks John, this is a good starting point.:clap:

If anyone else has an idea how to keep formatting, I'd be happy to know.

John Wilson
10-11-2016, 08:30 AM
Maybe something based on this


Sub Super_Typist3()
Dim WdApp As Object
Dim WdDoc As Object
Dim osld As Slide
Dim oshp As Shape
Err.Clear
On Error Resume Next
Set WdApp = GetObject(Class:="Word.Application")
If Err <> 0 Then
Set WdApp = CreateObject("Word.Application")
End If
WdApp.Visible = True
Set WdDoc = WdApp.Documents.Add
For Each osld In ActivePresentation.Slides
With WdApp.Selection
.ParagraphFormat.Alignment = 1
.TypeText "Slide: " & osld.SlideIndex
WdApp.Selection.TypeParagraph
End With
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
oshp.TextFrame.TextRange.Copy
WdApp.Selection.TypeText "Shape: " & oshp.Name & " >> "
WdApp.Selection.Paste
End If
End If
Next oshp
WdApp.Selection.TypeParagraph
Next osld
End Sub

isabelle r
10-12-2016, 12:26 AM
Thanks John, this is what I was looking for.