Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want each text from ppt file.i just want known how to read ppt file .which method is use? plaese help me.
my code is here
VB
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim oPowerPoint As PowerPoint.Application
    Dim oSlides As PowerPoint.Slides
    Dim oSlide As PowerPoint.Slide
    Dim oPres As PowerPoint.Presentations
    Dim oP As PowerPoint.Presentation
    Dim oShape As PowerPoint.Shapes
    Dim oSh As PowerPoint.Shape
    Dim strText As String
    Try
        oPowerPoint = CreateObject("PowerPoint.Application")
        oPowerPoint.Visible = True
        'oP = oPowerPoint.Presentations.Open(FileName:=TextBox1.Text, WithWindow:=Microsoft.Office.Core.MsoTriState.msoFalse)
        oP = oPowerPoint.Presentations.Open(TextBox1.Text)
        oP = oP.Application.ActivePresentation
        oSlides = oP.Slides
        For Each oSlide In oSlides
            oShape = oSlide.NotesPage.Shapes
            For Each oSh In oShape
                If oSh.HasTextFrame Then
                    If oSh.TextFrame.HasText Then
                        strText = oSh.TextFrame.TextRange.Text
                        MessageBox.Show(strText)
                    End If
                End If
            Next
        Next

        oPowerPoint.Quit()
        oPowerPoint = Nothing

    Catch ex As Exception
        MessageBox.Show(ex.StackTrace)
        MessageBox.Show(ex.Message)
    End Try
End Sub

it will give slide number not text on slide.so what is remaining in my code?
thank in advance!!!
Posted
Updated 8-Dec-11 4:09am
v4
Comments
luisnike19 8-Dec-11 10:10am    
Code tag added.

I solved my question .here is code for reading .ppt file contain differnt shape.
Dim oPowerPoint As PowerPoint.Application
Dim oSlides As PowerPoint.Slides
Dim oShapes As PowerPoint.Shapes
Dim oP As PowerPoint.Presentation
Dim oSh As PowerPoint.Shape
Dim it As String
Dim strText As String
'Dim sReplace1 As String = "ABC"

Dim i As Integer
Dim j As Integer
Dim Ctr As Integer
oPowerPoint = CreateObject("PowerPoint.Application")
oPowerPoint.Visible = True
oP = oPowerPoint.Presentations.Open(TextBox1.Text, , , Microsoft.Office.Core.MsoTriState.msoCTrue)
oP = oP.Application.ActivePresentation
i = oP.Slides.Count
For j = 1 To i
oShapes = oP.Slides(j).Shapes
For Each oSh In oShapes
With oSh
' .Select()
Select Case .Type
Case .Type.msoAutoShape
it = "an AutoShape. Type : " & .Type
Dim Trange As PowerPoint.TextRange = oSh.TextFrame.TextRange.Words(-1, -1)
strText = Trange.Text
MessageBox.Show(strText)
Trange.Text = sReplace1
Case .Type.msoCallout
it = "a Callout. Type : " & .Type
Case .Type.msoChart
it = "a Chart. Type : " & .Type
Case .Type.msoComment
it = "a Comment. Type : " & .Type
Case .Type.msoFreeform
it = "a Freeform. Type : " & .Type
Case .Type.msoGroup
it = "a Group. Type : " & .Type

' If it's a group them iterate thru
' the items and list them

it = it & vbCrLf & "Comprised of..."
For Ctr = 1 To .GroupItems.Count
it = it & vbCrLf & _
.GroupItems(Ctr).Name & _
". Type:" & .GroupItems(Ctr).Type
Next Ctr
Case .Type.msoEmbeddedOLEObject
it = "an Embedded OLE Object. Type : " & .Type
Case .Type.msoFormControl
it = "a Form Control. Type : " & .Type
Case .Type.msoLine
it = "a Line. Type : " & .Type
Case .Type.msoLinkedOLEObject
it = "a Linked OLE Object. Type : " & .Type
With .LinkFormat
it = it & vbCrLf & "My Source: " & _
.SourceFullName
End With
Case .Type.msoLinkedPicture
it = "a Linked Picture. Type : " & .Type
With .LinkFormat
it = it & vbCrLf & "My Source: " & _
.SourceFullName
End With
Case .Type.msoOLEControlObject
it = "an OLE Control Object. Type : " & .Type
Case .Type.msoPicture
it = "a embedded picture. Type : " & .Type
Case .Type.msoPlaceholder
Dim Trange As PowerPoint.TextRange
Dim oParagrphs As Object
Dim tbl As PowerPoint.Table
Dim r As Integer
Dim c As Integer
Dim strTable As String
it = "a text placeholder (title or regular text--" & _
"not a standard textbox) object." & _
"Type : " & .Type
If .HasTextFrame Then
If .TextFrame.HasText Then
oParagrphs = .TextFrame.TextRange.Paragraphs(-1, -1)
For Each Trange In oParagrphs
strText = Trange.Text
MessageBox.Show(strText)
Trange.Text = sReplace1
Next
End If
ElseIf .HasTable Then
.Select()
tbl = oSh.Table
For r = 1 To tbl.Rows.Count
For c = 1 To tbl.Columns.Count
strTable = tbl.Cell(r, c).Shape.TextFrame.TextRange.Text
MessageBox.Show(strTable)
tbl.Cell(r, c).Shape.TextFrame.TextRange.Text = sReplace1
Next
Next
End If
Case .Type.msoTextEffect
it = "a WordArt (Text Effect). Type : " & .Type
Case .Type.msoTextBox
it = "a Text Box."
Dim Trange As PowerPoint.TextRange = oSh.TextFrame.TextRange.Words(-1, -1)
strText = Trange.Text
MessageBox.Show(strText)
Trange.Text = sReplace1
Case .Type.msoShapeTypeMixed
it = "a Mixed object (whatever that might be)." & _
"Type : " & .Type
Case .Type.msoTable
it = " a Table. Type : " & .Type

'Just in case
Case Else
it = "a mystery!? An undocumented object type?" & _
" Haven't found one of these yet!"

End Select
MessageBox.Show("I'm " & it)
End With
Next
Next j
 
Share this answer
 
You may read only or more with corrupt powerpoint file fix

http://www.powerpoint.fixtoolboxx.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900