sunny k
sunny k

Reputation: 33

Copy data from powerpoint textbox to Excel cell

I am using macro in MS Excel to import data from textbox in PowerPoint to Excel.

It's importing data in text format not able to copy new line characters from textbox

Range("a1").Value = pps.Shapes("textbox 1").TextFrame.TextRange.Text

Can anyone please suggest alternative solution?

Upvotes: 0

Views: 2609

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14810

Recent versions of PowerPoint use Chr$(11) as a linebreak character. It looks like Excel wants a linefeed Chr$(10), so something like this:

Range("a1").Value = Replace(pps.Shapes("textbox 1").TextFrame.TextRange.Text,Chr$(11), Chr$(10))

PPT uses different characters for paragraph endings vs line breaks, and it varies somewhat between versions, so if you need to support PPT 2003 and prior, you'll need a bit more code.

This page on the PPT FAQ I maintain explains the details:

http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm

Upvotes: 2

Related Questions