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

时间:2014-07-31 18:20:30

标签: vba excel-vba excel

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

这是我现在的代码。 “\ n”确实会导致我正在编辑的文本框开始换行。可能吗?在其上下文中,代码完美地运行。确切的文本发送到文本框,而不是两行文本。

1 个答案:

答案 0 :(得分:3)

Vba中没有“\ n”而是你应该使用VbNewLine或VbCrLf或Vblf

替换此

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