Macro to insert symbols results in wrong font

W

wal

Word 2003, Windows XP

I have written simple macros, with keyboard shortcuts, to type in
certain symbols, such as the right arrow. For example:

Sub TypeRightArrow()
On Error GoTo bye
Selection.TypeText Text:=ChrW(8594) & " "
bye:
End Sub

My Normal template font is Arial. I have the Japanese feature
installed; the default Asian font is MS Mincho.

When I'm typing an ordinary English document in Arial and I invoke the
macro, the symbol comes up in MS Mincho. With some symbols, such as
the arrows, this doesn't matter visually. With others, such as bullet
points, the bullet looks terrible in MS Mincho. This problem continues
in a given document even if I turn off the Japanese feature (Start menu
Programs > Microsoft Office > Microsoft Office Tools > Microsoft Office 2003 Language Settings. (It does not happen if, after I turn off Japanese, I create a new document. Then, the symbols appear in Arial.) A further problem is that the MS Mincho character, when selected cannot be changed to Arial via the Font dialog or other means. It is stuck in MS Mincho.

I've since found a workaround:

Selection.InsertSymbol Font:="Arial", CharacterNumber:=8594,
Unicode:=True

So my question is kind of theoretical now: Under the first macro, why
does the symbol default to the default Asian font? This seems like a
bug. Also, it makes the TypeText command useless in many cases.

Thanks for any ideas.
 
J

John McGhie [MVP - Word and Word Macintosh]

Hi Wal:

TypeText is the old mechanism. InsertSymbol is the new mechanism, developed
specifically to solve the problem you have.

Most of VBA cannot pass Unicode. It's ANSI only. When you force a 16-bit
character on it, it will default to the font in use under the cursor at the
time, or to the first font it finds that contains the character.

InsertSymbol solves this by enabling you to specify the fonts.

Cheers


Word 2003, Windows XP

I have written simple macros, with keyboard shortcuts, to type in
certain symbols, such as the right arrow. For example:

Sub TypeRightArrow()
On Error GoTo bye
Selection.TypeText Text:=ChrW(8594) & " "
bye:
End Sub

My Normal template font is Arial. I have the Japanese feature
installed; the default Asian font is MS Mincho.

When I'm typing an ordinary English document in Arial and I invoke the
macro, the symbol comes up in MS Mincho. With some symbols, such as
the arrows, this doesn't matter visually. With others, such as bullet
points, the bullet looks terrible in MS Mincho. This problem continues
in a given document even if I turn off the Japanese feature (Start menu

I've since found a workaround:

Selection.InsertSymbol Font:="Arial", CharacterNumber:=8594,
Unicode:=True

So my question is kind of theoretical now: Under the first macro, why
does the symbol default to the default Asian font? This seems like a
bug. Also, it makes the TypeText command useless in many cases.

Thanks for any ideas.

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top