View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How do I display the ASCII hex values in text document?

That toggles the character with the HEX value - nice one. You learn
something new every day here ?

If you want the ASCII value try the following macro to determine the value
of a selected character (or characters).

Sub ANSIValue()
S1$ = "Because the selected text contains"
S2$ = " characters, not all of the ANSI values will be displayed."
S3$ = "ANSI Value ("
S4$ = " characters in selection)"
S5$ = " character in selection)"
S6$ = "Text must be selected before this macro is run."
S7$ = "ANSI Value"
Dim strSel As String
Dim strNums As String
Dim LastFourChar As String
Dim iPos As Integer
strSel = Selection.Text
If Len(strSel) 0 Then
For i = 1 To Len(strSel)
strNums = strNums + Str(Asc(Mid(strSel, i)))
Next i
strNums = LTrim(strNums)
If Len(strNums) 255 Then
LastFourChar = Mid(strNums, 252, 4)
strNums = Left(strNums, 251) + Left(LastFourChar, _
4 - InStr(" ", LastFourChar))
MsgBox S1$ + Str(Len(strSel)) + S2$
End If
If Len(strSel) = 1 Then S4$ = S5$
MsgBox strNums, 0, S3$ + LTrim(Str(Len(strSel))) + S4$
Else
MsgBox S6$, 0, S7$
End If
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Tony Jollans wrote:
Word 2002 and 2003 can give you the ascii value for a single
character if you select it and press Alt+X. I'm using 2000 at the
moment so can't check and I seem to recall that it didn't always work
exactly as I expected, but try it and see for yourself.


"capndave" wrote in message
...
I thought Word had a feature to show the actual hex values in a
document, but now I can't seem to remember how to change to that
view. I have some files that were ftp'd from a client and I need to
track down why the file contents are getting mangled.