dschmitt
10-05-2011, 09:50 PM
I often copy and paste text into an email. Sometimes each line has a carriage return (CR) which terminates the line. How does the script look like that would delete all CRs in a selected paragraph of text?
In Word I use the following script. It does not work in Outlook.
Sub DeleteCR()
With Selection
.Text = Replace(.Text, vbCr, " ")
End With
End Sub
In PowerPoint I use another script. That also doesn't work in Outlook.
Sub DeleteCRs()
Dim oshp As Shape
Dim otxt As TextRange
'check for type of selection
'replaces all text in shape unless
'text is highlighted
If ActiveWindow.Selection.Type = ppSelectionNone _
Or ActiveWindow.Selection.Type = ppSelectionSlides Then Exit Sub
If ActiveWindow.Selection.Type = ppSelectionShapes Then
Set oshp = ActiveWindow.Selection.ShapeRange(1)
Set otxt = oshp.TextFrame.TextRange
End If
If ActiveWindow.Selection.Type = ppSelectionText Then
Set otxt = ActiveWindow.Selection.TextRange
If Len(otxt) < 1 Then
Set otxt = otxt.Parent.Parent.TextFrame.TextRange
End If
End If
With otxt
.Text = Replace(.Text, vbCr, " ")
End With
With otxt
.Text = Replace(.Text, ". ", ". " & vbCr)
End With
End Sub
In Word I use the following script. It does not work in Outlook.
Sub DeleteCR()
With Selection
.Text = Replace(.Text, vbCr, " ")
End With
End Sub
In PowerPoint I use another script. That also doesn't work in Outlook.
Sub DeleteCRs()
Dim oshp As Shape
Dim otxt As TextRange
'check for type of selection
'replaces all text in shape unless
'text is highlighted
If ActiveWindow.Selection.Type = ppSelectionNone _
Or ActiveWindow.Selection.Type = ppSelectionSlides Then Exit Sub
If ActiveWindow.Selection.Type = ppSelectionShapes Then
Set oshp = ActiveWindow.Selection.ShapeRange(1)
Set otxt = oshp.TextFrame.TextRange
End If
If ActiveWindow.Selection.Type = ppSelectionText Then
Set otxt = ActiveWindow.Selection.TextRange
If Len(otxt) < 1 Then
Set otxt = otxt.Parent.Parent.TextFrame.TextRange
End If
End If
With otxt
.Text = Replace(.Text, vbCr, " ")
End With
With otxt
.Text = Replace(.Text, ". ", ". " & vbCr)
End With
End Sub