- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a VB.NET routine to find and replace text strings. I am snagging on formatted MTEXT
Case "AcDbMText"
Dim NewTextString As String = ""
Dim mtextObj As MText = trans.GetObject(selObj.ObjectId, OpenMode.ForWrite, False, True)
Dim OldTextString As String = mtextObj.Contents
NewTextString = Replace(OldTextString, CurrentFind, CurrentReplace, 1, -1, CompareMethod.Text)
If OldTextString <> NewTextString Then
mtextObj.Contents = NewTextString
End If
mtextObj.Dispose()
Right now the routine works a little too well, it replaces in formatting as well as the string. For instance if I replace "p" with "q" it takes out all the paragraph formatting under "\P". Is there a way to distinguish between actual visible and formatting. I was going to make an exceptions list but that would get rather lengthy and sticky especially when it comes to text styles.
Solved! Go to Solution.