根据老大的提示及poetbox兄的提示: 我写出如下的代码,测得所选文字的Ascii码。请大家测试: Sub 汉字转为Ascii码() '测得所选文字的ASCII码,并放到文档的最后 On Error Resume Next Dim a As Long Dim astring As String Dim intCon% Dim bstring As String astring = Selection.Text '选中文字 For a = 1 To Len(astring) intCon = VBA.AscW((Mid(astring, a, 1))) '在每个字中循环 If intCon < 0 Then '如果小于0,则用65536来减 bstring = bstring & Mid(astring, a, 1) & vbTab & intCon + 65536 & vbCrLf Else '如果大于0,则取AscW所取得的值 bstring = bstring & Mid(astring, a, 1) & vbTab & intCon & vbCrLf End If Next '写到文档的最后,另存一段 ActiveDocument.Content.InsertAfter Chr(13) & bstring End Sub
[此贴子已经被作者于2006-12-20 11:41:16编辑过] |