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

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

Posted by: admin April 23, 2020 Leave a comment

Questions:
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.

How to&Answers:

There is no “\n” in Vba instead you should use VbNewLine or VbCrLf or 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