Concatenate & Transpose from one file to another

Fenix Kage

New Member
Joined
Jul 5, 2015
Messages
1
I have a large project which involves taking the text from 500 powerpoints and inputting that into a single worksheet. I've found a PPT macro that will export the text from the active PPT to Alltext.CSV (worksheet: Alltext). When I try to have it export as an XLSX or XLSM, it won't open, so I hope having a CSV in the process won't be an issue; however, I don't believe it will since the macro itself will be running from an XLSM.

The data goes into the CSV with each row being a slide, and each slide taking up a random number of rows, sometimes with blank cells in between (as shown below). What I need is a macro that will concatenate those rows into one cell, ignoring the blank ones, and having " / " as a separator. Then transpose the resultant column into the first blank row of column H of the worksheet "PPT" in the file "MasterList.xlsm."

Here's an example of what I'm starting with from PPT1 in Alltext.csv

ABC
1234
DEF

<tbody>
</tbody>

And this is the result I need in MasterList.xlsm:

PPT1A / B / C1 / 2 / 3 / 4D / E / F
PPT2

<tbody>
</tbody>


Ultimately, the purpose is to allow me to search for a phrase in all the PPTs, and know exactly which file and page the phrase is located in.


Here is the starting PPT macro, in case it can be amended to do the job of both.

Code:
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 #iFile, sTempString
    sTempString = ""

  Next oSld

  'Close output file
  Close #iFile

End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,161
Messages
6,123,371
Members
449,097
Latest member
thnirmitha

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