PC Review


Reply
Thread Tools Rate Thread

Changing Chinese Font in Excel

 
 
=?Utf-8?B?QnVuc29u?=
Guest
Posts: n/a
 
      18th Sep 2007
I got many files containing Chinese and English charater in same cells. I
need to convert those Chinese text into a special font. But Excel does not
provide any function to distinguish Chinese and English character in same
cell. It's very time consuming to change those font type manually. Does
anyone know if there is any Macro program code can speed up thise process?
 
Reply With Quote
 
 
 
 
Bill Renaud
Guest
Posts: n/a
 
      18th Sep 2007
In Excel 2000, if I put 9 characters in a cell (i.e. "abcdefghi") that
are formatted as "Times New Roman", then format the middle 3 as
"WingDings" (i.e. "def" formatted), then run the following test code:

Public Sub Test()
Dim rngCell As Range
Dim lngIndex As Long

Set rngCell = ActiveCell

For lngIndex = 1 To Len(rngCell.Value)
Debug.Print lngIndex, rngCell.Characters(lngIndex).Font.Name
Next lngIndex
End Sub

I get the following results in the Immediate window:

1 Null
2 Null
3 Null
4 Null
5 Null
6 Null
7 Times New Roman
8 Times New Roman
9 Times New Roman

This is only partially correct, as characters 1-3 should also be "Times
New Roman". Maybe newer versions of Excel have improved the Characters
object. If it would work on your system, then you might be able to use
it to step through each character to find out whether the font had been
changed to some other font.
--
Regards,
Bill Renaud



 
Reply With Quote
 
Zone
Guest
Posts: n/a
 
      18th Sep 2007
Bunson, Standard English characters normally end at ASCII code 126. If the
font you are using obeys this rule, then this may work for you. Copy this
code and paste in a standard module. Select some cells you want to change
and run the macro, changing "Webdings" to the name of the special font you
want to use. Might work. Let me know! James

Sub Test()
Dim k As Integer, cell As Range
For Each cell In Selection
For k = 1 To Len(cell)
With cell.Characters(Start:=k, Length:=1)
If AscW(.Text) > 126 Then .Font.Name = "Webdings"
End With
Next k
Next cell
End Sub



"Bunson" <(E-Mail Removed)> wrote in message
news:598501BE-CCBB-456C-ACB4-(E-Mail Removed)...
>I got many files containing Chinese and English charater in same cells. I
> need to convert those Chinese text into a special font. But Excel does
> not
> provide any function to distinguish Chinese and English character in same
> cell. It's very time consuming to change those font type manually. Does
> anyone know if there is any Macro program code can speed up thise process?



 
Reply With Quote
 
Zone
Guest
Posts: n/a
 
      18th Sep 2007
Interesting, Bill. I get the same result on Excel 2003. James
"Bill Renaud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In Excel 2000, if I put 9 characters in a cell (i.e. "abcdefghi") that
> are formatted as "Times New Roman", then format the middle 3 as
> "WingDings" (i.e. "def" formatted), then run the following test code:
>
> Public Sub Test()
> Dim rngCell As Range
> Dim lngIndex As Long
>
> Set rngCell = ActiveCell
>
> For lngIndex = 1 To Len(rngCell.Value)
> Debug.Print lngIndex, rngCell.Characters(lngIndex).Font.Name
> Next lngIndex
> End Sub
>
> I get the following results in the Immediate window:
>
> 1 Null
> 2 Null
> 3 Null
> 4 Null
> 5 Null
> 6 Null
> 7 Times New Roman
> 8 Times New Roman
> 9 Times New Roman
>
> This is only partially correct, as characters 1-3 should also be "Times
> New Roman". Maybe newer versions of Excel have improved the Characters
> object. If it would work on your system, then you might be able to use
> it to step through each character to find out whether the font had been
> changed to some other font.
> --
> Regards,
> Bill Renaud
>
>
>



 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      18th Sep 2007
I assumed that this result was the due to the fact that I use a template
to create all of my workbooks, and the default font in it is "Times New
Roman". So I might have expected the result to be as shown below,
because the first 3 characters would just follow the default in the
template. Character 4 would be the first location where a change would
be needed.

1 Null
2 Null
3 Null
4 WingDings
5 WingDings
6 WingDings
7 Times New Roman
8 Times New Roman
9 Times New Roman

Then you might have a chance at detecting where the new font begins and
ends, so those characters could be converted, or removed.
--
Regards,
Bill Renaud



 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      18th Sep 2007
Sorry, I made a mistake when I tried the routine previously. I forgot to
specify a single character (1) in the argument list to the Characters
property! (I had a cell with 9 characters in it, with the 3 middle ones
formatted as "Wingdings", instead of the default "Times New Roman".)

Public Sub ShowCharacters()
Dim rngCell As Range
Dim lngIndex As Long

Set rngCell = ActiveCell

For lngIndex = 1 To rngCell.Characters.Count
Debug.Print lngIndex, rngCell.Characters(lngIndex, 1).Font.Name
Next lngIndex
End Sub

Produces the following output in the Immediate window:

1 Times New Roman
2 Times New Roman
3 Times New Roman
4 Wingdings
5 Wingdings
6 Wingdings
7 Times New Roman
8 Times New Roman
9 Times New Roman

This should give you a start in figuring out where the Chinese
characters are located and then removing them or converting them to
something else.
--
Regards,
Bill Renaud



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel freezes when changing font Ellshere Microsoft Excel Crashes 0 1st Feb 2010 09:32 PM
Excel 2003 traditional chinese to simplified chinese =?Utf-8?B?U0hP?= Microsoft Excel Misc 0 1st Dec 2006 05:23 AM
Excel with Trad. Chinese version hang when printing Simp Chinese Francis Microsoft Excel Crashes 0 9th Sep 2004 05:36 PM
Changing the font color in an Excel footer =?Utf-8?B?TGF1cmEgYXQgQ2hlbHNlYQ==?= Microsoft Excel Misc 2 1st May 2004 06:06 PM
Changing Font case in excel =?Utf-8?B?QW5kcmV3IFMu?= Microsoft Excel Misc 8 21st Feb 2004 08:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:15 PM.