首页 > 办公 > Word > 正文

word用VBA快速输入拼音

2024-08-22 13:31:56
字体:
来源:转载
供稿:网友

   输入时输入对应的元音加声调,然后利用VBA统一替换,这样速度快多了。

  如:she1ng dia4o

  选中后,运行下面的宏就可得到:

  shēng diào

  对于有时要输入小学语文类的拼音尤其有用。可以考虑把这个宏放到对应的模板中。

  VBA代码如下:

  Dim findarr, replacearr

  Dim i As Long

  Application.ScreenUpdating = False

  findarr = Array("a1", "a2", "a3", "a4", _

  "o1", "o2", "o3", "o4", _

  "e1", "e2", "e3", "e4", _

  "i1", "i2", "i3", "i4", _

  "u1", "u2", "u3", "u4", _

  "v1", "v2", "v3", "v4")

  replacearr = Array("ā", "á", "ǎ", "à", _

  "ō", "ó", "ǒ", "ò", _

  "ē", "é", "ě", "è", _

  "ī", "í", "ǐ", "ì", _

  "ū", "ú", "ǔ", "ù", _

  "ǖ", "ǘ", "ǚ", "ǜ")

  For i = 0 To UBound(findarr)

  With Selection.Find

  .Execute findarr(i), MatchWildcards:=False, Format:=False, replacewith:=replacearr(i), Replace:=wdReplaceAll

  End With

  Next

  Application.ScreenUpdating = True

  End Sub

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表