-1

Beginner needs help writing Word Macro for productivity gain in language studies using Phonetic Guide Ruby Text in Word 2019

I'm studying Chinese, have the Chinese language pack and keyboard installed. What I want to do is to cut down the number of mouse clicks required to turnon/off the display of Ruby which is done via using the Phoentic guide.

By hand this means selcting my Chinese character text, Home Menu/ Font grouping/ Phonetic Guide/ Offset=5, Size=10/ OK

I cannot then select another piece of text and reapply.

Therein lies my problem, as for language lists,reading passages etc I want to turn the Ruby one for those characters or groups of characters I don't know, then turn them off as my confidence at reading them without the Pinyin grows.

In addition it is not possibe to select a whole passage and them apply Phonet ic guide, it seemingly only does some unknown number of characters at a time. Totally frustrating and I have reported this elsewhere to no avail, so onward to try to find a workaround

My thoughts are that as a work around is to write a Macro button which would do this for me for any selction of text I select

If anyone can think of a better solutions I'd be glad to hear it. It will save my hours over the next months/years of learning.

Now I've never written a macro before and so begun by using the Record button, this got me a Macro which is as follows

Sub AddRuby2()
'
' AddRuby2 Macro
'
'
    With Selection
        .Start = 877
        .End = 879
        .Range.PhoneticGuide Text:="wù", Alignment:= _
            wdPhoneticGuideAlignmentOneTwoOne, Raise:=15, FontSize:=8, FontName _
            :="Microsoft YaHei"
    End With
    With Selection
        .Start = 877
        .End = 877
        .Range.PhoneticGuide Text:="ji" & ChrW(257), Alignment:= _
            wdPhoneticGuideAlignmentOneTwoOne, Raise:=15, FontSize:=8, FontName _
            :="Microsoft YaHei"
    End With
End Sub

BUT that doesn't do what I want and I don't know how to get it to do it.

I can see how to write adjustments to the Raise and Font Size, that's clear enough

  1. how do I get it to work on the text I select?

    ie not

     With Selection
         .Start = 877
         .End = 879
    

    AND

  2. how do I get it to work with whatever characters I select to run the Marco on ie not the "wu" and "ji" which were in the selction I chose when recording?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
sheila
  • 1
  • It is unclear what this question has to do with [tag:ruby]. I don't see any Ruby nor any Ruby question. – Jörg W Mittag Feb 22 '21 at 15:56
  • Cross-posted at: https://answers.microsoft.com/en-us/msoffice/forum/all/help-required-to-write-a-macro/23e5034e-986b-41fa-8b96-b5d1e921da2c. For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184 – macropod Feb 22 '21 at 23:13

1 Answers1

0

Try this ...

With Selection
    .Range.PhoneticGuide Text:=Selection.Range.Text, Alignment:= _
        wdPhoneticGuideAlignmentOneTwoOne, Raise:=15, FontSize:=8, FontName _
        :="Microsoft YaHei"
End With

It's the same answer I provided you yesterday on MS-Answers.

Rich Michaels
  • 1,663
  • 2
  • 12
  • 18
  • Thanks Rich I just found your reply there, and my reply is the same I get a Compile error with this. I posted here after posting in MS-answers thinking this might be a bit iore of a programmers thread. I am really struggling to get Phonetics Guide to work in a useful way I havent had an y answers on MS_answers to my post https://answers.microsoft.com/en-us/msoffice/forum/all/can-i-change-the-font-size-setting-permenantly-on/5bea0982-803d-487d-986c-76785dde6c58 You dont happen to know where the defaults are set for Offset and Pinyin Font Size? – sheila Feb 22 '21 at 17:55