Using two fonts

G

Greg Willis

Hi,

The Tooth Faerie periodically responds to letters from my daughter by
writing using a TTF font called "FairyScrollDisplay". The problem is
that the font contains alpha characters, but no numerals or punctuation
marks. It takes a lot of time to edit the document so that alpha
characters display in FairyScroll and other characters in another font,
such as Times New Roman.

Right now the document is composed in Times New Roman, 18 pts. I created
a style called "fairy" using "FairyScrollDisplay" in 18 pts. The
document is then converted to FairyScroll by selecting individual blocks
of text and converting them to the "Fairy" style, leaving punctuation
and numerals intact in the Times New Roman font.

Is there a shortcut or workaround that will cut down on manual editing?
It would save the Tooth Faerie some sleepless nights spent editing
documents, and allow her to devote more time to building her castle with
all those teeth she is collecting!

Thanks in advance for any assistance,

Greg
 
G

Guest

Hi Greg,

You could use a macro to accomplish this. It doesn't work with styles though.

Record any macro, say record clicking the B-button on the Formatting
toolbar, and be sure to choose Normal.dot under 'Store macro in'.
Choose Tools | Macro > Macro's..., select your macro and choose Edit. The
VBA-editor opens.
Replace the entire macro by the following:

Sub TTF()
With Selection
.HomeKey Unit:=wdStory
.MoveRight Extend:=wdExtend

While .End < ActiveDocument.Range.End
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", UCase(.Text)) Then
.Font.Name = "FairyScrollDisplay"
Else
.Font.Name = "Times New Roman"
End If
.MoveRight
.MoveRight Extend:=wdExtend
Wend
End With
End Sub

Click the Save button in the VBA editor to save Normal.dot. Close the VBA
editor. In Word, choose Tools | Macro > Macros... Select TTF and click Run.

Any letter will be put in FairyScrollDisplay while any other character will
be put in Times New Roman.
Beware: the macro skips tables.

Good luck,
Cooz
 
G

Greg

<Record any macro, say record clicking the B-button on the Formatting
<toolbar, and be sure to choose Normal.dot under 'Store macro in'.
<Choose Tools | Macro > Macro's..., select your macro and choose Edit.
The
<VBA-editor opens.

Why not just: Press ALT+F11

And instead of cycling through each letter (while understandably
insignificant in a letter from the tooth fairy it might be laborious in
say War and Peace) why not start out with Time New Roman and then
something like:
Sub TTF1()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "FairyScrollDisplay"
.Execute Replace:=wdReplaceAll
End With
End Sub

Seems faster and as a bonus it doesn't skip tables.
 
G

Guest

As another bonus, it applies FairyScrollDisplay to [ \ ] ^ _ and `.
Perhaps I'm squabbling, but, well, they're not letters.

Cooz
 
G

Greg

Well touche. I suppose we have both learned a lesson of the importance
of testing. Good thing this was just a letter to the tooth fairy.
 
G

Greg

Cooz,

I haven't dug into the inconsistencies wrt the range [A-z] processing
the six characters your test revealed. Still I think it better to
process as much of a document in bulk as possible and then go back and
sort out the cats and dogs. Perhaps something like:

Sub TTF2()
Dim oRng As Word.Range
Dim myArray As Variant
Dim i As Long
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "Arial"
.Execute Replace:=wdReplaceAll
End With
myArray = Split("`,[,],^,_,\", ",")
For i = 0 To UBound(myArray)
With oRng.Find
.MatchWildcards = False
.Text = myArray(i)
.Replacement.Text = "^&"
.Replacement.Font.Name = "Times New Roman"
.Execute Replace:=wdReplaceAll
End With
Next i
End Sub
 
G

Greg

Cooz,

It appears that the behavior is due to the character codes of those six
characters.

A-Z is 65 though 90. a is 97

[\]^_` are 91-96

So we can do tow passes [A-Z] and [a-z] instead of using the array
suggested earlier.

Sub TTF3()
Dim oRng As Word.Range
Dim myArray As Variant
Dim i As Long
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-Z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "Arial"
.Execute Replace:=wdReplaceAll
.Text = "[a-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "Arial"
.Execute Replace:=wdReplaceAll
End With
End Sub
 
G

Greg

Hmm...learning as I go. We can combine the two ranges A-Z and a-z in
one pass:

Sub TTF2()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-Za-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "FairScrollDisplay"
.Execute Replace:=wdReplaceAll
End With
End Sub
 
G

Greg

Cooz,

Not sqaubbling, I poked you in the eye for improper testing and it is
only fair to be poked back. ;-)

I have used the range [A-z] many times in find and replace and I was
never stung until today. The fact that these six characters will creep
in isn't covered in friend Graham Mayor's article on using: wildcards:
http://www.gmayor.com/replace_using_wildcards.htm

He is probably reading this thread but I plan to mention it to him off
line just the same.
 
S

Suzanne S. Barnhill

*From* the tooth fairy.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Guest

We keep each other alert. Nothing wrong with that. I must have had a
momentary lapse of about everything when I suggested the macro I suggested -
and boy, do I regret it.

Cooz
 
G

Guest

Hi Greg,

It's me again.

I find that recording a simple macro functions perfectly as a placeholder:
"Hey, user! Type/Paste here!" The macro is selected as soon as the VBA-editor
is open.
Most users haven't ever seen the VBA-editor and do not desire to see it.
Now, they can put in their code and leave it, and be certain that it is in
the right place.

"Press Alt+F11" doesn't do that.

Cooz
 
S

Suzanne S. Barnhill

But Tools | Macro | Macros | Create works just as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Cooz said:
Hi Greg,

It's me again.

I find that recording a simple macro functions perfectly as a placeholder:
"Hey, user! Type/Paste here!" The macro is selected as soon as the VBA-editor
is open.
Most users haven't ever seen the VBA-editor and do not desire to see it.
Now, they can put in their code and leave it, and be certain that it is in
the right place.

"Press Alt+F11" doesn't do that.

Cooz


Greg said:
<Record any macro, say record clicking the B-button on the Formatting
<toolbar, and be sure to choose Normal.dot under 'Store macro in'.
<Choose Tools | Macro > Macro's..., select your macro and choose Edit.
The
<VBA-editor opens.

Why not just: Press ALT+F11

And instead of cycling through each letter (while understandably
insignificant in a letter from the tooth fairy it might be laborious in
say War and Peace) why not start out with Time New Roman and then
something like:
Sub TTF1()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "FairyScrollDisplay"
.Execute Replace:=wdReplaceAll
End With
End Sub

Seems faster and as a bonus it doesn't skip tables.
 
G

Greg

Cooz,

I suppose everyone has an opinion. Personnally I think your suggested
method risks insulting the intelligence of some users. It's like
saying "Here, do this ... because I doubt the you care about the
details (or worse, because I doubt that you are bright enough to grasp
the details).

Remember, give the man a fish and he eats for a day. Teach the man to
fish and he eats for a lifetime.
 
G

Guest

Yeah...
I've been pondering this, and I think in the future I'll refer to the
websites you mentioned earlier. That 'll do.

Thanx,
Cooz
 
G

Guest

Yes, it does.
--
PS: Werkt deze oplossing voor jou en log je in via de Microsoft site, klik
dan svp even op Yes bij "Did this post answer the question?". Bedankt.


Suzanne S. Barnhill said:
But Tools | Macro | Macros | Create works just as well.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Cooz said:
Hi Greg,

It's me again.

I find that recording a simple macro functions perfectly as a placeholder:
"Hey, user! Type/Paste here!" The macro is selected as soon as the VBA-editor
is open.
Most users haven't ever seen the VBA-editor and do not desire to see it.
Now, they can put in their code and leave it, and be certain that it is in
the right place.

"Press Alt+F11" doesn't do that.

Cooz


Greg said:
<Record any macro, say record clicking the B-button on the Formatting
<toolbar, and be sure to choose Normal.dot under 'Store macro in'.
<Choose Tools | Macro > Macro's..., select your macro and choose Edit.
The
<VBA-editor opens.

Why not just: Press ALT+F11

And instead of cycling through each letter (while understandably
insignificant in a letter from the tooth fairy it might be laborious in
say War and Peace) why not start out with Time New Roman and then
something like:
Sub TTF1()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Content
With oRng.Find
.MatchWildcards = True
.Text = "[A-z]"
.Replacement.Text = "^&"
.Replacement.Font.Name = "FairyScrollDisplay"
.Execute Replace:=wdReplaceAll
End With
End Sub

Seems faster and as a bonus it doesn't skip tables.
 

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