问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/37773668/copy-data-from-powerpoint-textbox-to-excel-cell