We help IT Professionals succeed at work.

Macro to change Fonts

460 Views
Last Modified: 2013-12-03
Hello,

I need some help to develop a macro to work in Word so that every time a character is encountered, it changes it to font EurekaSans-Regular, and when it encounters a number, it changes it to font EurekaSans-RegularCaps.....what I have so far is

----
Selection.HomeKey Unit:=wdStory
    Selection.EndKey Unit:=wdStory, Extend:=wdExtend
   
    If Asc(Selection.Text) >= 48 And Asc(Selection.Text) <= 57 Then
           Selection.Font.Name = "EurekaSans-RegularCaps"
            Selection.MoveRight
    End If

   If Asc(Selection.Text) >= 65 And Asc(Selection.Text) <= 122 Then
           Selection.Font.Name = "EurekaSans-Regular"
            Selection.MoveRight
    End If
-----

but I can't make to scan the entire document......

Please help!!

Thanks

C
Comment
Watch Question

Retired
CERTIFIED EXPERT
Top Expert 2012
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Joanne M. OrzechManager, Document Services Center
Top Expert 2004

Commented:
Nice job Graham!  I didn't think of a wildcard search and replace.  That's why you get the big points!  LOL
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
Thanks Jo. My maths master always said the simplest way is the best way.

Author

Commented:
Excellent job!!!!

Thanks

C
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.