C
Co
Hi All,
I want to open a ppt and extract the text but without ppt actualy
being shown.
I get an error saying there is no presentation open.
What do I do wrong?
Public Function Iterate_Through_All_Shapes(FName As String)
Dim ppApp As Object
Dim iShape As Integer
Dim iNotesShape As Integer
Dim iSlide As Integer
Dim NotesText As String
Dim FileNum As Integer
Set ppApp = CreateObject("powerpoint.application")
With ppApp
.Activate
.Presentations.Open FileName:=FName, ReadOnly:=False
.Visible = True
.WindowState = ppWindowMinimized
End With
For iSlide = 1 To ppApp.ActivePresentation.Slides.Count
With ppApp.ActivePresentation.Slides(iSlide)
'tekst uit de slide halen
For iShape = 1 To .Shapes.Count
With .Shapes(iShape)
If .HasTextFrame And .TextFrame.HasText Then
NotesText = NotesText
& .TextFrame.TextRange.Text & vbCrLf & vbCrLf
End If
End With
Next iShape
'eventueel tekst uit de notespage halen
For iNotesShape = 1 To .NotesPage.Shapes.Count
With .NotesPage.Shapes(iNotesShape)
If .HasTextFrame And .TextFrame.HasText Then
NotesText = NotesText
& .TextFrame.TextRange.Text & vbCrLf & vbCrLf
End If
End With
Next iNotesShape
End With
Next iSlide
FileNum = FreeFile
Open ppApp.ActivePresentation.Path & "\" &
Left(ppApp.ActivePresentation.Name, _
Len(ppApp.ActivePresentation.Name) - 4) & ".txt" For Output
As FileNum
Print #FileNum, NotesText
Close FileNum
ppApp.Quit
Set ppApp = Nothing
End Function
Marco
I want to open a ppt and extract the text but without ppt actualy
being shown.
I get an error saying there is no presentation open.
What do I do wrong?
Public Function Iterate_Through_All_Shapes(FName As String)
Dim ppApp As Object
Dim iShape As Integer
Dim iNotesShape As Integer
Dim iSlide As Integer
Dim NotesText As String
Dim FileNum As Integer
Set ppApp = CreateObject("powerpoint.application")
With ppApp
.Activate
.Presentations.Open FileName:=FName, ReadOnly:=False
.Visible = True
.WindowState = ppWindowMinimized
End With
For iSlide = 1 To ppApp.ActivePresentation.Slides.Count
With ppApp.ActivePresentation.Slides(iSlide)
'tekst uit de slide halen
For iShape = 1 To .Shapes.Count
With .Shapes(iShape)
If .HasTextFrame And .TextFrame.HasText Then
NotesText = NotesText
& .TextFrame.TextRange.Text & vbCrLf & vbCrLf
End If
End With
Next iShape
'eventueel tekst uit de notespage halen
For iNotesShape = 1 To .NotesPage.Shapes.Count
With .NotesPage.Shapes(iNotesShape)
If .HasTextFrame And .TextFrame.HasText Then
NotesText = NotesText
& .TextFrame.TextRange.Text & vbCrLf & vbCrLf
End If
End With
Next iNotesShape
End With
Next iSlide
FileNum = FreeFile
Open ppApp.ActivePresentation.Path & "\" &
Left(ppApp.ActivePresentation.Name, _
Len(ppApp.ActivePresentation.Name) - 4) & ".txt" For Output
As FileNum
Print #FileNum, NotesText
Close FileNum
ppApp.Quit
Set ppApp = Nothing
End Function
Marco