1

I have code that automatically detects certain text based on a selection and places onto a user form.

The issue I face is removing the trailing paragraph marker. (see picture below):

enter image description here

I have tried the following and other variations, but I can't remove the trailing paragraph marker:

Dim theText As String
theText = Replace(Selection, "^p", "") 

Lastly, I know I can use Left(Selection,Len(Selection)-1), but this will fail if the paragraph marker is not there.

Scott Holtzman
  • 27,099
  • 5
  • 37
  • 72

2 Answers2

1

To get the paragraph in Word, use one of the following 2 options (the first works for the OP):

  • theText = Replace(Selection, ChrW$(13), "")

  • theText = Replace(Selection, ChrW$(244), "")

Vityata
  • 42,633
  • 8
  • 55
  • 100
0

As provided in the comments above this is the solution:

Dim theText As String
theText = Replace(Selection, Chr(13), "")
Scott Holtzman
  • 27,099
  • 5
  • 37
  • 72