' Kritidev 010 to Unicode Converter Macro for MS Word
' First version in April 2011.
' Current upadate 26-11-2015
' This selects changes all the Kruti Dev 010 font text and changes it to Unicode (Mangal/Kokila etc).
' If you are copy pasting some text which is Krutidev10 but format is not set, first select the text and set its format as "Kriti Dev 010". Then use the Converter.
Sub ReplaceText(Text As String, ReplacementText As String)
With Selection.Find
.Text = Text
.Replacement.Text = ReplacementText
.Format = True ' to search only in Kruti Dev 010
.MatchCase = True
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.MatchWildcards = False ' simple text search
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub ReplaceRegExpression(Text As String, ReplacementText As String)
' Selection.Find.ClearFormatting
' Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = Text
.Replacement.Text = ReplacementText
.Format = False ' this is required because two fonts (Krutidev10 and Mangal) are to be handled now.
.MatchCase = False
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True ' for regualr expressions
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub Krutidev10_to_Unicode_Converter()
' remove comment (ie, ') and choose parameters, for example .size = 12
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Font
.Name = "Kruti Dev 010" ' select KrutiDev10 font text for replacement
' .Size = 10
' .Bold = False
' .Italic = True
' .Color = wdColorRed
End With
' ///////////////
' ( chrW (40)
' ) chrW (41)
' { chrW (123)
' } chrW (125)
' [ chrW (91)
' ] chrW (93)
' . chrW (46)
' * chrW (42)
' ^ chrW (94)
' + chrW (43)
' \ chrW (92)
' / chrW (47)
' ? chrW (63)
' //////////////
ReplaceText "å", ChrW(2406)
ReplaceText "ƒ", ChrW(2407)
ReplaceText "„", ChrW(2408)
ReplaceText "…", ChrW(2409)
ReplaceText "†", ChrW(2410)
ReplaceText "‡", ChrW(2411)
ReplaceText "ˆ", ChrW(2412)
ReplaceText "‰", ChrW(2413)
ReplaceText "Š", ChrW(2414)
ReplaceText "‹", ChrW(2415)
ReplaceText "<", ChrW(2338)
ReplaceText ">", ChrW(2333)
ReplaceText "&", ChrW(45)
ReplaceText "~ ", "å" & ChrW(32)
'ReplaceText "Ùk", ChrW(2340) & "å" & ChrW(2340)
ReplaceText "Ù", ChrW(2340) & "å" & ChrW(2340) & "å"
ReplaceText "ä", ChrW(2325) & "å" & ChrW(2340)
ReplaceText "–", ChrW(2342) & ChrW(2371)
ReplaceText "—", ChrW(2325) & ChrW(2371)
ReplaceText "à", ChrW(2361) & "å" & ChrW(2344)
ReplaceText "á", ChrW(2361) & "å" & ChrW(2351)
ReplaceText "â", ChrW(2361) & ChrW(2371)
ReplaceText "ã", ChrW(2361) & "å" & ChrW(2350)
ReplaceText "ºz", ChrW(2361) & "å" & ChrW(2352)
ReplaceText "º", ChrW(2361) & "å"
ReplaceText "í", ChrW(2342) & "å" & ChrW(2342)
'ReplaceText ChrW(123) & "k", ChrW(2325) & "å" & ChrW(2359)
ReplaceText ChrW(123), ChrW(2325) & "å" & ChrW(2359) & "å"
ReplaceText "=", ChrW(2340) & "å" & ChrW(2352)
ReplaceText "«", ChrW(2340) & "å" & ChrW(2352) & "å"
ReplaceText "Nî", ChrW(2331) & "å" & ChrW(2351)
ReplaceText "Vî", ChrW(2335) & "å" & ChrW(2351)
ReplaceText "Bî", ChrW(2336) & "å" & ChrW(2351)
ReplaceText "Mî", ChrW(2337) & "å" & ChrW(2351)
' ReplaceText "&lt;î" , chrW(2338) & "å" & chrW(2351)
ReplaceText "|", ChrW(2342) & "å" & ChrW(2351)
ReplaceText "K", ChrW(2332) & "å" & ChrW(2334)
ReplaceText ChrW(125), ChrW(2342) & "å" & ChrW(2357)
ReplaceText "J", ChrW(2358) & "å" & ChrW(2352)
ReplaceText "Vª", ChrW(2335) & "å" & ChrW(2352)
ReplaceText "Mª", ChrW(2337) & "å" & ChrW(2352)
' ReplaceText "&lt;ªª" , chrW(2338) & "å" & chrW(2352)
ReplaceText "Nª", ChrW(2331) & "å" & ChrW(2352)
ReplaceText "Ø", ChrW(2325) & "å" & ChrW(2352)
ReplaceText "Ý", ChrW(2347) & "å" & ChrW(2352)
ReplaceText "æ", ChrW(2342) & "å" & ChrW(2352)
ReplaceText "ç", ChrW(2346) & "å" & ChrW(2352)
ReplaceText "Á", ChrW(2346) & "å" & ChrW(2352)
ReplaceText "xz", ChrW(2327) & "å" & ChrW(2352)
ReplaceText "#", ChrW(2352) & ChrW(2369)
ReplaceText ":", ChrW(2352) & ChrW(2370)
ReplaceText "vks", ChrW(2323)
ReplaceText "vkS", ChrW(2324)
ReplaceText "vk", ChrW(2310)
ReplaceText "v", ChrW(2309)
ReplaceText "b±", ChrW(2312) & ChrW(2306)
ReplaceText "Ã", ChrW(2312)
ReplaceText "bZ", ChrW(2312)
ReplaceText "b", ChrW(2311)
ReplaceText "m", ChrW(2313)
ReplaceText "Å", ChrW(2314)
ReplaceText ",s", ChrW(2320)
ReplaceText ",", ChrW(2319)
ReplaceText "_", ChrW(2315)
ReplaceText "ô", ChrW(2325) & "å" & ChrW(2325)
ReplaceText "d", ChrW(2325)
'ReplaceText "Dk", ChrW(2325)
ReplaceText "D", ChrW(2325) & "å"
'ReplaceText ChrW(91) & "k", ChrW(2326)
ReplaceText ChrW(91), ChrW(2326) & "å"
ReplaceText "x", ChrW(2327)
'ReplaceText "Xk", ChrW(2327)
ReplaceText "X", ChrW(2327) & "å"
ReplaceText "Ä", ChrW(2328)
ReplaceText ChrW(63) & "k", ChrW(2328)
ReplaceText ChrW(63), ChrW(2328) & "å"
ReplaceText "³", ChrW(2329)
ReplaceText "pkS", ChrW(2330) & ChrW(2376)
ReplaceText "p", ChrW(2330)
'ReplaceText "Pk", ChrW(2330)
ReplaceText "P", ChrW(2330) & "å"
ReplaceText "N", ChrW(2331)
ReplaceText "t", ChrW(2332)
'ReplaceText "Tk", ChrW(2332)
ReplaceText "T", ChrW(2332) & "å"
' ReplaceText "&gt;" , chrW(2333)
ReplaceText "÷", ChrW(2333) & "å"
ReplaceText "¥", ChrW(2334)
ReplaceText "ê", ChrW(2335) & "å" & ChrW(2335)
ReplaceText "ë", ChrW(2335) & "å" & ChrW(2336)
ReplaceText "V", ChrW(2335)
ReplaceText "B", ChrW(2336)
ReplaceText "ì", ChrW(2337) & "å" & ChrW(2337)
ReplaceText "ï", ChrW(2337) & "å" & ChrW(2338)
ReplaceText "M+", ChrW(2337) & ChrW(2364)
' ReplaceText "&lt;+" , chrW(2338) & chrW(2364)
ReplaceText "M", ChrW(2337)
' ReplaceText "&lt;" , chrW(2338)
'ReplaceText ".k", ChrW(2339)
ReplaceText ".", ChrW(2339) & "å"
ReplaceText "r", ChrW(2340)
'ReplaceText "Rk", ChrW(2340)
ReplaceText "R", ChrW(2340) & "å"
'ReplaceText "Fk", ChrW(2341)
ReplaceText "F", ChrW(2341) & "å"
ReplaceText ChrW(41), ChrW(2342) & "å" & ChrW(2343)
ReplaceText "n", ChrW(2342)
'ReplaceText "èk", ChrW(2343)
ReplaceText "è", ChrW(2343) & "å"
'ReplaceText ChrW(47) & "k", ChrW(2343)
ReplaceText ChrW(47), ChrW(2343) & "å"
ReplaceText "Ë", ChrW(2343) & "å"
ReplaceText "u", ChrW(2344)
'ReplaceText "Uk", ChrW(2344)
ReplaceText "U", ChrW(2344) & "å"
ReplaceText "i", ChrW(2346)
'ReplaceText "Ik", ChrW(2346)
ReplaceText "I", ChrW(2346) & "å"
ReplaceText "Q", ChrW(2347)
ReplaceText "¶", ChrW(2347) & "å"
ReplaceText "c", ChrW(2348)
'ReplaceText "Ck", ChrW(2348)
ReplaceText "C", ChrW(2348) & "å"
'ReplaceText "Hk", ChrW(2349)
ReplaceText "H", ChrW(2349) & "å"
ReplaceText "e", ChrW(2350)
'ReplaceText "Ek", ChrW(2350)
ReplaceText "E", ChrW(2350) & "å"
ReplaceText ";", ChrW(2351)
ReplaceText "¸", ChrW(2351) & "å"
ReplaceText "j", ChrW(2352)
ReplaceText "y", ChrW(2354)
'ReplaceText "Yk", ChrW(2354)
ReplaceText "Y", ChrW(2354) & "å"
ReplaceText "G", ChrW(2355)
ReplaceText "o", ChrW(2357)
'ReplaceText "Ok", ChrW(2357)
ReplaceText "O", ChrW(2357) & "å"
'ReplaceText "'k", ChrW(2358)
ReplaceText "'", ChrW(2358) & "å"
'ReplaceText "k"" , chrW(2359)"
ReplaceText """", ChrW(2359) & "å"
ReplaceText "l", ChrW(2360)
'ReplaceText "Lk", ChrW(2360)
ReplaceText "L", ChrW(2360) & "å"
ReplaceText "g", ChrW(2361)
ReplaceText "È", ChrW(2368) & ChrW(2306)
ReplaceText "z", "å" & ChrW(2352)
ReplaceText "Ì", ChrW(2342) & "å" & ChrW(2342)
ReplaceText "Í", ChrW(2335) & "å" & ChrW(2335)
ReplaceText "Î", ChrW(2335) & "å" & ChrW(2336)
ReplaceText "Ï", ChrW(2337) & "å" & ChrW(2337)
ReplaceText "Ñ", ChrW(2325) & ChrW(2371)
ReplaceText "Ò", ChrW(2349)
ReplaceText "Ó", "å" & ChrW(2351)
ReplaceText "Ô", ChrW(2337) & "å" & ChrW(2338)
ReplaceText "Ö", ChrW(2333) & "å"
ReplaceText "Ø", ChrW(2325) & "å" & ChrW(2352)
ReplaceText "Ù", ChrW(2340) & "å" & ChrW(2340) & "å"
ReplaceText "Ü", ChrW(2358) & "å"
ReplaceText "v‚", ChrW(2321)
ReplaceText "a", ChrW(2306)
ReplaceText "¡", ChrW(2305)
ReplaceText "%", ChrW(2307)
ReplaceText "~j", "å" & ChrW(2352)
ReplaceText "~", "å"
ReplaceText ChrW(92), ChrW(63)
ReplaceText ChrW(94), ChrW(8216)
ReplaceText ChrW(42), ChrW(8217)
ReplaceText "Þ", ChrW(8220)
ReplaceText "ß", ChrW(8221)
ReplaceText ChrW(41), ChrW(59)
ReplaceText "¼", ChrW(40)
ReplaceText "½", ChrW(41)
ReplaceText "¿", ChrW(123)
ReplaceText "À", ChrW(125)
ReplaceText "¾", ChrW(61)
ReplaceText "A", ChrW(2404)
ReplaceText "-", ChrW(46)
' ReplaceText "&" , chrW(45)
' ReplaceText "&" , chrW(181)
ReplaceText "Œ", ChrW(2416)
ReplaceText ChrW(93), ChrW(44)
ReplaceText ChrW(43), ChrW(2364)
' ReplaceText "åk", ""
ReplaceRegExpression "åk", "" ' because å is in Mangal at this point while k is in Krutidev10.
' ////////////////////////
' substitution of chotee i
ReplaceRegExpression "([f])([" & ChrW(2325) & "-" & ChrW(2361) & "])", "\2\1"
ReplaceRegExpression "([f])([å])([" & ChrW(2325) & "-" & ChrW(2361) & "])", "\2\3\1"
ReplaceRegExpression "([f])([å])([" & ChrW(2325) & "-" & ChrW(2361) & "])", "\2\3\1"
'ReplaceText "f", ChrW(2367) ' choti i
' ------
' replaceing Reph
'------
' ([????????????????????????????????????])([??????????]*)Z --> Z$1$2
ReplaceRegExpression "ZZ", "Z" ' remove repeated reph
ReplaceRegExpression "([khqwsSWf]{1,4})([Z])", "\2\1"
ReplaceRegExpression "([" & ChrW(2325) & "-" & ChrW(2361) & "])Z", "Z\1"
ReplaceRegExpression "([" & ChrW(2325) & "-" & ChrW(2361) & "])åZ", "Z\1å"
ReplaceRegExpression "Z", ChrW(2352) & ChrW(2381) ' ra + halanta
ReplaceRegExpression "å", ChrW(2381) ' here the replacement is to be done format free because å have Mangal font.
ReplaceRegExpression "([khqwsSWf])\1", "\1" ' if same maatraa is repeated keep one only
' replace the maatraas now
ReplaceText "‚", ChrW(2377)
ReplaceText "ks", ChrW(2379)
ReplaceText "kS", ChrW(2380)
ReplaceText "k", ChrW(2366)
ReplaceText "h", ChrW(2368)
ReplaceText "q", ChrW(2369)
ReplaceText "w", ChrW(2370)
ReplaceText "`", ChrW(2371)
ReplaceText "s", ChrW(2375)
ReplaceText "S", ChrW(2376)
ReplaceText "W", ChrW(2373)
ReplaceText "•", ChrW(2365)
ReplaceText "·", ChrW(2365)
ReplaceText "f", ChrW(2367)
' maatraa errors (use ReplaceRegExpression as maatraas are in Mangal at this point)
' ansuswaar + maatraa --> maatraa + anusaar
ReplaceRegExpression "([" & ChrW(2306) & "])([" & ChrW(2377) & ChrW(2379) & ChrW(2380) & ChrW(2366) & ChrW(2368) & ChrW(2369) & ChrW(2370) & ChrW(2371) & ChrW(2375) & ChrW(2376) & ChrW(2373) & ChrW(2365) & ChrW(2365) & ChrW(2367) & "]{1,3})", "\2\1"
' Now make (change) all Kruti Dev 010 text as Unicode
' following lines copied from internet.
Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges
With rngStory.Find
.Text = "" ' Do not find or replace anything
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Font.Name = "Kruti Dev 010"
.Replacement.Font.Name = "Mangal" ' kokila may also be used.
End With
rngStory.Find.Execute Replace:=wdReplaceAll
Next rngStory
End Sub ' end of Krutidev10 to Unicode Converter subroutine