在VC中输入Tchar麻烦,所以写了个宏方便使用。
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 
posted on 2005-12-02 08:26 孤独的夜 阅读(331) 评论(0)  编辑 收藏 引用 所属分类: VC Skill


标题  
姓名  
主页
验证码 *
内容(提交失败后,可以通过“恢复上次提交”恢复刚刚提交的内容)
 
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
[使用Ctrl+Enter键可以直接提交]
 
相关链接: