将数据从Powerpoint文本框复制到Excel单元格
我正在使用MS Excel中的宏将数据从PowerPoint的文本框中导入到Excel.
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?
PowerPoint的最新版本使用Chr $(11)作为换行符.看来Excel想要换行Chr $(10),所以像这样:
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段落结尾和换行符使用不同的字符,并且版本之间有所不同,因此,如果需要支持PPT 2003及更早版本,则需要更多代码.
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.
我维护的PPT常见问题解答上的此页面详细说明:
This page on the PPT FAQ I maintain explains the details:
http://www.pptfaq.com/FAQ00992_Paragraph_endings_and_line_breaks.htm