这在.NET和VBA中均有显示。男性标志:
♂
你会注意到第4,5,6,8,10和12行,那里有一个额外的角色。这是一个段落标记。第3行是制表符,但只显示为空格。
当我尝试在PowerPoint中抓取.TextRange.Text
的文本时会发生这种情况。上面是VBE中的立即窗口,但是当我尝试将文本放在控件中时,它也会显示.NET控件,例如ListView。
可以通过打开一个新的PowerPoint演示文稿然后在VBE中运行来复制它:
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
如何摆脱这种情况(即只显示男性标志)?这是我的控件的某种Unicode设置还是字符串上的RegEx或......?
答案 0 :(得分:0)
听起来像Powerpoint没有使用VB正在使用的相同的回车换行约定。您可能必须使用不同的换行约定替换vbCrLf(使您自己的字节数组对要插入)。
答案 1 :(得分:0)
而非vbCrLf
使用此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
答案 2 :(得分:0)
本文将帮助Exploring the PowerPoint TextRange Object,但请注意,当它来自标题占位符时,它是Chr(11)而不是Chr(13)。您可以使用TextRange.Replace(ChrW(11), " ")
对其进行清理。