First of I agreed with Jason
Second, you got me man, indeed
Please do not ask me personaly,
I will not help you again, this is very
basics, see Help
~'J'~
Sub AddPrefToMText()
Dim oSset As AcadSelectionSet
Dim oEnt As AcadObject
Dim fcode(1) As Integer
Dim fData(1) As Variant
Dim dxfcode, dxfdata
Dim i As Integer
Dim setName As String
setName = "$MTEXTS$"
For i = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(i).Name = setName Then
ThisDrawing.SelectionSets.Item(i).Delete
Exit For
End If
Next i
Set oSset = ThisDrawing.SelectionSets.Add(setName)
Dim pref As String, newpref As String
pref = InputBox(vbNewLine & "Enter prefix to search" & vbNewLine & _
"press Enter to set default", _
"MText Prefix", "%%C")
newpref = InputBox(vbNewLine & "Enter prefix to replace" & vbNewLine & _
"press Enter to set default", _
"MText Prefix", "%%30")
fcode(0) = 0: fData(0) = "MTEXT"
fcode(1) = 1: fData(1) = pref & "*" '// <-- build mask
dxfcode = fcode
dxfdata = fData
oSset.Select acSelectionSetAll, , , dxfcode, dxfdata
' MsgBox oSset.Count 'debug only
If oSset.Count > 0 Then
Dim oMText As AcadMText
For Each oMText In oSset
Dim txtStr As String
txtStr = oMText.TextString
oMText.TextString = newpref & Right$(oMText.TextString, Len(oMText.TextString) - Len(pref))
Next
End If
End Sub