Question

This shows up in both .NET and in VBA. The male sign:

mo fo

You'll notice on lines 4, 5, 6, 8, 10 and 12 there is an extra character there. This is from a paragraph mark. On line 3 is a tab character, but that just shows up as spaces.

This happens when I try to grab the text of a .TextRange.Text in PowerPoint. Above is the Immediate Window in the VBE, but it also shows up .NET controls when I try to put the text in a control, such as a ListView.

It can be replicated by opening a new PowerPoint presentation and then in the VBE running:

Sub Replicate()
    Dim ap As Presentation: Set ap = ActivePresentation
    Dim sl As Slide: Set sl = ap.Slides(1)
    sl.Shapes.Title.TextFrame.TextRange.Text = "One bad" & vbCrLf & "MOFO"
    Debug.Print s.Shapes.Title.TextFrame.TextRange.Text
End Sub

How can I get rid of this (i.e. just show nothing in place of the male sign)? Is this some kind of Unicode setting for my controls or RegEx on the string or...?

Was it helpful?

Solution

This article will help Exploring the PowerPoint TextRange Object, but note that when it's from a title placeholder it is Chr(11) instead of Chr(13). You can use a TextRange.Replace(ChrW(11), " ") on it to clean it up.

OTHER TIPS

Sounds like Powerpoint is not using the same carriage-return line-feed convention that VB is using. You might have to replace the vbCrLf with a different newline convention (make your own byte array pair to insert).

instead of vbCrLf Use this vbLf & vbCr

Sub Replicate()
    Dim ap As Presentation: Set ap = ActivePresentation
    Dim sl As Slide: Set sl = ap.Slides(1)
    sl.Shapes.Title.TextFrame.TextRange.Text = "One bad" & vbLf & vbCr & "Line Feed above me"
End Sub

alt text

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top