VBA code to extract organisation flowchart text in excel/csv (who reports to whom)

Ankita Tulshyan

New Member
Joined
Apr 18, 2019
Messages
1
Sub ExportTextToCSV()

Dim oPres As Presentation
Dim oSlides As Slides
Dim oSld As Slide 'Slide Object
Dim oShp As Shape 'Shape Object
Dim iFile As Integer 'File handle for output
Dim sTempString As String

Dim PathSep As String
Dim Quote As String
Dim Comma As String
iFile = FreeFile 'Get a free file number

#If Mac Then
PathSep = ":"
#Else
PathSep = ""
#End If

Quote = Chr$(34)
Comma = ","

Set oPres = ActivePresentation
Set oSlides = oPres.Slides

'Open output file
' NOTE: errors here if original PPT file hasn't been saved
Open oPres.Path & PathSep & "AllText.CSV" For Output As iFile

For Each oSld In oSlides 'Loop thru each slide
For Each oShp In oSld.Shapes 'Loop thru each shape on slide

'Check to see if shape has a text frame and text
If oShp.HasTextFrame And oShp.TextFrame.HasText Then
sTempString = sTempString & Quote & oShp.TextFrame.TextRange.Text & Quote & Comma
End If

Next oShp

' print the result to file:
Print #If ile, sTempString
sTempString = ""

Next oSld

'Close output file
Close #If ile

End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top