ms word vba macro to convert a selection - Decimal to Hex code, Hex Code to Decimal

82 views
Skip to first unread message

V S Rawat

unread,
Dec 5, 2017, 6:47:35 AM12/5/17
to th
Sub cnvCode_Dec2Hex()
Selection.Text = Hex(Selection.Text)
End Sub
Sub cnvCode_Hex2Dec()
Selection.Text = CDec("&h" & Selection.Text)
End Sub


Write a Decimal code and/ or hex code of a character in ms word.

try for GREEK SMALL LETTER ALPHA
α
decimal 945
hex 03B1

select that one code at a time (it should get highlighted)

go to Menu - Developer - Macro

click on cnvCode_Dec2Hex to convert Decimal to Hex code
click on cnvCode_Hex2Dec to convert Hex Code to Decimal

Your selected code will be replaced, you can press Undo ^Z to bring your
original code back.

What is the use?

in MS Word, if you select any character and press Alt X, it will show
the char code of that char.

This code is in hex.

but if you go to Find box, you need to write only decimal values.

like, in Find box
- you can directly write decimal ascii codes by prefixing them with \,
as \999, like \013 is for carriage return (CR ^p)
- you can write decimal unicode codes by prefixing them with \u, as
\u99999, like \u945 is for above mentioned "alpha".

""""You can't put hex values in Find box."""

So, Word gives hex value by Alt X, but you can't use them in find box,
so you need to quickly convert them to decimal.

Funny? No, irritating indeed.

For that purpose, instead of going to ishida site, these tiniest macros
would come handy.

Thanks.
--
Rawat

हरिराम

unread,
Dec 6, 2017, 7:31:44 AM12/6/17
to technic...@googlegroups.com
MS Excel में भी

=HEX2DEC(B1)

और

=DEC2HEX(B1)

कमांड भलीभाँति कार्य करती हैं।

(B1) के स्थान पर उस सेल को रखें जिसमें डिसिमल या हेक्स कोड है।



हरिराम
प्रगत भारत <http://hariraama.blogspot.in>


--
Rawat

--
आपको यह संदेश इसलिए प्राप्त हुआ क्योंकि आपने Google समूह "Scientific and Technical Hindi (वैज्ञानिक तथा तकनीकी हिन्दी)" समूह की सदस्यता ली है.
इस समूह की सदस्यता समाप्त करने और इससे ईमेल प्राप्त करना बंद करने के लिए, technical-hindi+unsubscribe@googlegroups.com को ईमेल भेजें.
अधिक विकल्‍पों के लिए, https://groups.google.com/d/optout पर जाएं.

V S Rawat

unread,
Dec 6, 2017, 9:49:40 AM12/6/17
to technic...@googlegroups.com
जी हाँ, एक्सेल में तो फ़ंक्शन के कारण कई चीजों का सुभीता हो जाता है,
समस्या वर्ड में ज़रा सा काम करने में आती है।

धन्यवाद।
रावत
> technical-hin...@googlegroups.com
> <mailto:technical-hindi%2Bunsu...@googlegroups.com> को ईमेल भेजें.
> अधिक विकल्‍पों के लिए, https://groups.google.com/d/optout
> <https://groups.google.com/d/optout> पर जाएं.
>
>
> --
> आपको यह संदश इसलिए मिला है क्योंकि आपने Google समूह के "Scientific and
> Technical Hindi (वैज्ञानिक तथा तकनीकी हिन्दी)" समूह की सदस्यता ली है.
> इस समूह की सदस्यता समाप्त करने और इससे ईमेल प्राप्त करना बंद करने के लिए,
> technical-hin...@googlegroups.com
> <mailto:technical-hin...@googlegroups.com> को ईमेल भेजें.
> अधिक विकल्पों के लिए, https://groups.google.com/d/optout में जाएं.
Reply all
Reply to author
Forward
0 new messages