VBA - 如何将换行命令 (\n) 或制表符命令 (\t) 发送到 PowerPointS 形状的 textbox.textrange.text

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25066225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:02:57  来源:igfitidea点击:

VBA - How do I send new line command (\n) or tab command (\t) to a textbox.textrange.text of a PowerPointS Shape

vbaexcel-vbaexcel

提问by kennedy484

SlideNumber = 1
Set oPPTSlide = oPPTFile.Slides(SlideNumber)

For y = 1 To oPPTSlide.Shapes.Count
    MsgBox oPPTSlide.Shapes(y).Name
Next

With oPPTSlide.Shapes("Title 1")
    .TextFrame.TextRange.Text = _ 
               "Operations Monthly Report\n" & _
               "April " & _
               "2014"
End With

This is the code I have now. The "\n" does cause the text-box I am editing to start a new line. Is it possible? The code, in its context, is working perfectly. The exact text is sent to the text-box though, not two lines of text.

这是我现在拥有的代码。"\n" 确实导致我正在编辑的文本框开始一个新行。是否可以?该代码在其上下文中运行良好。确切的文本被发送到文本框,而不是两行文本。

采纳答案by Jagadish Dabbiru

There is no "\n" in Vba instead you should use VbNewLine or VbCrLf or Vblf

Vba 中没有“\n”,您应该使用 VbNewLine 或 VbCrLf 或 Vblf

Replace this

替换这个

SlideNumber = 1
Set oPPTSlide = oPPTFile.Slides(SlideNumber)

For y = 1 To oPPTSlide.Shapes.Count
    MsgBox oPPTSlide.Shapes(y).Name
Next

With oPPTSlide.Shapes("Title 1")
    .TextFrame.TextRange.Text = _ 
               "Operations Monthly Report" & VbCrLf & _
               "April " & _
               "2014"
End With