在VC中输入Tchar麻烦,所以写了个宏方便使用。
// VS2005
Sub ChangeToTChar()
'DESCRIPTION: Change Normal String to T Char String, TChar String to Normal String.
Dim doc
doc = ActiveDocument
' Be sure active document is a text document
If doc Is Nothing Then
Exit Sub
ElseIf doc.Type <> "Text" Then
Exit Sub
End If
Dim CurrText
Dim CurrTextLen
CurrText = doc.Selection.Text
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If CurrTextLen = 0 Then
CurrText = " TEXT(""" & CurrText & """)"
doc.Selection.Text = CurrText
doc.Selection.CharLeft(2)
Else
If Mid(CurrText, 1, 1) = """" Then
'MsgBox Mid(CurrText,CurrTextLen,1)
If Mid(CurrText, CurrTextLen, 1) = """" Then
CurrText = " TEXT(" & CurrText & ") "
Else
Exit Sub
End If
ElseIf Mid(CurrText, 1, 2) = "_T" Then
CurrText = Mid(CurrText, 3, CurrTextLen - 2)
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If Mid(CurrText, 1, 1) = "(" And Mid(CurrText, CurrTextLen, 1) = ")" Then
CurrText = Mid(CurrText, 2, CurrTextLen - 2)
Else
Exit Sub
End If
ElseIf Mid(CurrText, 1, 4) = "TEXT" Then
CurrText = Mid(CurrText, 5, CurrTextLen - 4)
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If Mid(CurrText, 1, 1) = "(" And Mid(CurrText, CurrTextLen, 1) = ")" Then
CurrText = Mid(CurrText, 2, CurrTextLen - 2)
Else
Exit Sub
End If
Else
'Here Are Not String
'CurrText = " _T(""" & CurrText & """) "
Exit Sub
End If
doc.Selection.Text = CurrText
End If
End Sub
// VS2003
Sub ChangeToTChar()
'DESCRIPTION: Change Normal String to T Char String, TChar String to Normal String.
Dim doc
Set doc = ActiveDocument
' Be sure active document is a text document
If doc Is Nothing Then
Exit Sub
Elseif doc.Type <> "Text" Then
Exit Sub
End If
Dim CurrText
Dim CurrTextLen
Set CurrText = doc.Selection
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If CurrTextLen = 0 Then
CurrText = " TEXT(""" & CurrText & """)"
doc.Selection = CurrText
doc.Selection.CharLeft dsMove, 2
Else
If Mid(CurrText,1,1) = """" Then
'MsgBox Mid(CurrText,CurrTextLen,1)
If Mid(CurrText,CurrTextLen,1) = """" Then
CurrText = " TEXT(" & CurrText & ") "
Else
Exit Sub
End If
ElseIf Mid(CurrText,1,2) = "_T" Then
CurrText = Mid(CurrText,3,CurrTextLen-2)
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If Mid(CurrText,1,1) = "(" and Mid(CurrText,CurrTextLen,1) = ")" Then
CurrText = Mid(CurrText,2,CurrTextLen-2)
Else
Exit Sub
End If
ElseIf Mid(CurrText,1,4) = "TEXT" Then
CurrText = Mid(CurrText,5,CurrTextLen-4)
CurrText = Trim(CurrText)
CurrTextLen = Len(CurrText)
If Mid(CurrText,1,1) = "(" and Mid(CurrText,CurrTextLen,1) = ")" Then
CurrText = Mid(CurrText,2,CurrTextLen-2)
Else
Exit Sub
End If
Else
'Here Are Not String
'CurrText = " _T(""" & CurrText & """) "
Exit Sub
End If
doc.Selection = CurrText
End If
End Sub