A job I frequently need to do is to change a particular Japanese
character, ℃, which is a degree sign plus a C, into a Western style
degree sign plus a C, as in °C. In Word, it is easy for me to find and
replace the character. However, after I have done that, I am left with
the degree sign in the Japanese font. If I select the degree sign and
then change the font to Times New Roman, Word changes it correctly,
but I have not been able to automate this process. Strategies I've
tried include:
1. Recording a macro as I change the font. This fails because the
macro is empty - nothing is recorded.
2. Writing a macro and explicitly requesting a change of font name.
I've tried the following two ideas:
a. Selection.Font.Name = "Times New Roman"
b. Selection.Font.NameFarEast = "Times New Roman"
c. Selection.LanguageID = wdEnglishUS
Idea a. simply does nothing - the selected text remains in its
original state, and as far as I can see "Times New Roman" is added to
the style.
Idea b. causes a crash:
> Run-time error '5844':
>
> One of the values passed to this method or property is incorrect.
Idea c. doesn't do anything.
Note that changing the language (idea c) or changing the font (idea a)
in Word both achieve the correct result.
I can't think of anything else to try, so does anyone have a good
idea?
Klaus Linke - 21 Dec 2007 03:38 GMT
Your ideas a and c together should do the trick.
I use something like
Selection.Find.ClearFormatting
With Selection.Find
.Text = ChrW(8451)
.Forward = True
.Wrap = wdFindContinue
.Format = False
End With
While Selection.Find.Execute
Selection.Delete
Selection.Text = "oC"
Selection.LanguageID = wdEnglishUS
Selection.Font.Name = "Times New Roman"
Wend
It seems you can't get it to work doing a simple ReplaceAll... I guess because the change in font does not really take effect until you've changed the language.
Regards,
Klaus
>A job I frequently need to do is to change a particular Japanese
> character, ℃, which is a degree sign plus a C, into a Western style
[quoted text clipped - 32 lines]
> I can't think of anything else to try, so does anyone have a good
> idea?
benkasminbullock@gmail.com - 21 Dec 2007 04:47 GMT
> Your ideas a and c together should do the trick.
>
[quoted text clipped - 13 lines]
> Selection.Font.Name = "Times New Roman"
> Wend
Thank you for your assistance, but unfortunately this method doesn't
seem to work for me - the problem with the degree being a Japanese
symbol with a big piece of whitespace on its right doesn't go away.
Klaus Linke - 21 Dec 2007 11:29 GMT
You do use the degree sign Alt+0176?
Selection.Text = "°C"
What's the font of the degree sign?
The problem has driven me mad in the past, too. Sometimes I've cut the text, used Selection.Font.Reset, and then pasted unformatted.
Regards,
Klaus
>> Your ideas a and c together should do the trick.
>>
[quoted text clipped - 17 lines]
> seem to work for me - the problem with the degree being a Japanese
> symbol with a big piece of whitespace on its right doesn't go away.