- UID
- 5244
- 积分
- 1648
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
发表于 2002-11-9 19:36:46
|
显示全部楼层
附上一段程序,你可以试一试。
- [FONT=courier new]
- '注意本程序只更改字体和颜色,在使用前请先使用格式刷更改其它格式
- Sub Test()
- Dim EntObj As AcadEntity
- Dim pPt As Variant
- Dim sTextString As String
- Dim iFontPos As Integer
- Dim sFont As String
- Dim iColorPos As Integer
- Dim sColor As String
-
- On Error GoTo ErrTrap
- ThisDrawing.Utility.GetEntity EntObj, pPt, "指定参照的多行文本: "
- EntObj.Highlight True '实体亮显
- If Not (TypeOf EntObj Is AcadMText) Then
- EntObj.Highlight False
- Exit Sub
- End If
- sTextString = EntObj.TextString
- iFontPos = InStr(sTextString, "\f")
- sFont = Mid(sTextString, iFontPos, InStr(iFontPos, sTextString, ";") - iFontPos) '要参照的多行文本字体格式
- iColorPos = InStr(sTextString, "\C")
- If iColorPos <> 0 Then sColor = Mid(sTextString, iColorPos, InStr(iColorPos, sTextString, ";") - iColorPos) '要参照的多行文本颜色格式
- ThisDrawing.Utility.GetEntity EntObj, pPt, "指定变更的多行文本: "
- If Not (TypeOf EntObj Is AcadMText) Then Exit Sub
- sTextString = EntObj.TextString
- iFontPos = InStr(sTextString, "\f")
- EntObj.TextString = Left(sTextString, iFontPos - 1) & sFont & Mid(sTextString, InStr(iFontPos, sTextString, ";"))
- sTextString = EntObj.TextString
- iColorPos = InStr(sTextString, "\C")
- If iColorPos = 0 Then '要变更的多行文本颜色格式不存在
- iFontPos = InStr(sTextString, "\f")
- iFontPos = InStr(iFontPos, sTextString, ";")
- If sColor <> "" Then EntObj.TextString = Left(sTextString, iFontPos) & sColor & ";" & Mid(sTextString, iFontPos + 1)
- Else
- If sColor = "" Then '要参照的多行文本颜色格式不存在
- EntObj.TextString = Left(sTextString, iColorPos - 1) & Mid(sTextString, InStr(iColorPos, sTextString, ";") + 1)
- Else
- EntObj.TextString = Left(sTextString, iColorPos - 1) & sColor & Mid(sTextString, InStr(iColorPos, sTextString, ";"))
- End If
- End If
- Set EntObj = Nothing
- ThisDrawing.Regen acActiveViewport
- Exit Sub
-
- ErrTrap:
- If ThisDrawing.GetVariable("errno") = 7 Then Resume
- If Not (EntObj Is Nothing) Then
- EntObj.Highlight False
- Set EntObj = Nothing
- End If
- On Error GoTo 0
- End Sub
- [/FONT]
|
|