word给整篇文章注释拼音

问题描述:近期给小孩打印课文,想到加注拼音方便小孩阅读。

目标:给每个汉字标注拼音,同时为了方便阅读每个汉字之间预留一个空格。(因为word注音如果不空格,拼音连在一起不便区分)

遇到的困难:word 2016的注音功能只能给大概二三十字一次性注音(未详细数到底多少),对于成百上千字的文档注音就很繁琐

解决方法:使用word中的宏,在网上搜集资料找到这篇文章:

https://www.cnblogs.com/DreamlikeAttic/p/3655863.html

对它做了一些修改,步骤如下:

     1) 删掉了宏中分隔文字的片段:(有这段代码的宏处理速度会大大降低,且word总是崩溃)

     2)使用word中替换命令,实现文字的自动分隔,(分隔速度极快)

                  Ctrl+H(替换快捷键)->  “空格^&”(不含引号)并把高级选项中的 “使用通配符”打开。

     3)调好预期的字体,大小等等

    4)运行如下宏

Sub AddPinYin()
'Author:MissileCat Date:20140410 version:1.0.0
' Addpinyin 宏
'为一篇完整的word文字加上标音标注

    Dim tintTreatingCount As Integer
    Dim tstrCharA As String
    Dim tlngCurPos As Long
    Dim tintA As Integer


    Selection.WholeStory
    tstrText = Selection.Text
    tintTextLength = Selection.Characters.Count
    tintlinestart = 1

    tintTreatingCount = 0

    Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=1

   Selection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
   
    Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=1
    
    For tintloopx = 1 To tintTextLength
     
      tlngCurPos = Selection.MoveRight(unit:=wdCharacter, Count:=1, Extend:=wdExtend)
      
      tstrCharA = Right(Selection.Text, 1)
      If AscW(tstrCharA) < 255 And AscW(tstrCharA) > -255 Then
      
        If tintTreatingCount > 0 Then
            tintA = Len(Selection.Text)
        
            SendKeys "{enter}", 1
            Application.Run MacroName:="FormatPhoneticGuide"
             
            Selection.MoveRight unit:=wdCharacter, Count:=tintA

            tintTreatingCount = 0

        End If
      
      Else
      
         tintTreatingCount = tintTreatingCount + 1
      
      End If
      
    Next
    
End Sub

按照我这个顺序执行,最大的优点就是正确率高,(我实验的几次都没有出现错误),但是原作者的方法有很多漏注的字,但是也存在很大的缺点就是,速度慢。

    原因是我先分隔汉字,然后注音,就是每个字都执行一次注音程序,而原作者方法是多个字一注音。

  如有大神有更快的方法,希望给我评论。

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值