This line of code...
MyRange = MyRange.Paragraphs(1).Range 'Intended to select the paragraph ' that contained the previous range
...enters text right where the previous range was. I figured it out via pressing F8 in VBE for step by step execution. It concretely pastes the paragraph that the range defined in this line is supposed to encompass. This is driving me crazy as the line is just assigning a new range value to MyRange...
Why is doing so??
For example, having ths text selected:
"Author: CMV Subject: Highlight Date: 12/2/2014, 2:23:41 PM [As a VB /VBA developer you] glue the various"
Results in
"Author: CMV Subject: Highlight Date: 12/2/2014, 2:23:41/Author: CMV Subject: Highlight Date: 12/2/2014, 2:23:41 PM
[As a VB /VBA developer you] glue the various"
The text pasted corresponds to the paragraph (you can't see paragraph marks here) referred in this code line. It is pasted over the string the code searches for previously. I'm inserting the whole code just in case:
Set MyRange = Selection.Range
With MyRange.Find 'Busca _AM o _PM
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
.Text = " [AP]M"
.Execute
End With
MyRange = MyRange.Paragraphs(1).Range
An issue with these previous lines is posted here (in case it matters): VBA: Why is Range.Find.Execute deselecting text in a Word doc? (posted as there was other issue with them, but it seems unrelated to this to me)...
Can anyone figure out what's going on here? Please?