Copy data from powerpoint textbox to Excel cell

两盒软妹~` 提交于 2020-06-18 09:25:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!