Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macro doesn't work with 03 (office 2003)

    I had a macro for changing fonts that worked fine in Word 97, but does not work in Word 03. The macro would search for all small letters [a-z] and replace them with the same letters, but with a dfferent font. So, I would type something in Times New Roman, and then want to change all the lowercase letters to Times New Roman Expert font. But the macro doesn't recognize the Font part of the formattng.

    If I do the search and replace manually, the font DOES change. It is just when using the macro that it doesn't work. I'm assuming something in the programming statements have changed in the new version.

    I got some help from this forum years ago on this macro. I'm hoping someone can help me out again. I can post the macro code if that would help.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: macro doesn't work with 03 (office 2003)

    Hi,

    Yes, it would help if you could post the code, or at least a link to the original post. It's unlikely, however, that something that worked with Word 97 would fail to work with a later version of Word.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro doesn't work with 03 (office 2003)

    I've tried it on 2 different computers with Word 2003 and it didnt work. I went to the school library and started up an older computer that still have Word 97 on it and it worked fine. Here is the code: (I have 6 different Expert Fonts)

    Dim TF$
    Dim x$
    Dim tf_
    ReDim ReplaceFont__$(6)
    ReDim FindFont__$(6)
    TF$ = WordBasic.[InputBox$]("1. TNR 2. Baskerville 3. Bell 4. Garamond 5. Janson 6. Imprint ", " Expert Font To Use ")
    x$ = WordBasic.[Left$](TF$, 1)
    TF$ = x$
    If TF$ = "1" Then tf_ = 1
    If TF$ = "2" Then tf_ = 2
    If TF$ = "3" Then tf_ = 3
    If TF$ = "4" Then tf_ = 4
    If TF$ = "5" Then tf_ = 5
    If TF$ = "6" Then tf_ = 6
    If tf_ <> 1 And tf_ <> 2 And tf_ <> 3 And tf_ <> 4 And tf_ <> 5 And tf_ <> 6 Then tf_ = 1
    ReplaceFont__$(1) = "Times NR Expert MT"
    ReplaceFont__$(2) = "Bskvill Exp MT"
    ReplaceFont__$(3) = "Bell Expert MT"
    ReplaceFont__$(4) = "Garamond Expert MT"
    ReplaceFont__$(5) = "Janson Expert MT"
    ReplaceFont__$(6) = "Imprint Expert MT"

    FindFont__$(1) = "Times New Roman"
    FindFont__$(2) = "Baskerville MT"
    FindFont__$(3) = "Bell MT"
    FindFont__$(4) = "Garamond MT"
    FindFont__$(5) = "Janson MT"
    FindFont__$(6) = "Imprint MT"

    WordBasic.EditFindFont Points:="", Underline:=-1, Color:=-1, StrikeThrough:=-1, Superscript:=-1, Subscript:=-1, Hidden:=-1, SmallCaps:=-1, AllCaps:=-1, Spacing:="", Position:="", Kerning:=-1, KerningMin:="", Tab:="0", Font:=FindFont__$(tf_), Bold:=0, Italic:=0

    WordBasic.EditReplaceFont Points:="", Underline:=-1, Color:=-1, StrikeThrough:=-1, Superscript:=-1, Subscript:=-1, Hidden:=-1, SmallCaps:=-1, AllCaps:=-1, Spacing:="", Position:="", Kerning:=-1, KerningMin:="", Tab:="0", Font:=ReplaceFont__$(tf_), Bold:=0, Italic:=0
    WordBasic.EditReplace Find:="[a-z,0-9]", Replace:="^&", Direction:=0, MatchCase:=1, WholeWord:=0, PatternMatch:=1, SoundsLike:=0, ReplaceAll:=1, Format:=1, Wrap:=0

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro doesn't work with 03 (office 2003)

    This is a WordBasic macro converted to VBA. WordBasic was the programming language in Word 95 and before. Although it should still function in Word 2003 (and it does work as intended for me in Word 2003 SP2), it's better to switch to VBA. I have attached a VBA version of the code.
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro doesn't work with 03 (office 2003)

    BTW, are you really sure this is a good idea? By changing only lower-case letters and digits to a different font, you are introducing a lot of overhead - a 6 page document I tried it on went from 75 KB to 95 KB.

  6. #6
    2 Star Lounger
    Join Date
    Mar 2001
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macro doesn't work with 03 (office 2003)

    I don't change an entire document, it's usually just titles or headings that I change. On the old verson, it would only change what was highlghted.

    Odd thing, though--my 'main' computer at school and my computer at home still will not run my old macro correctly, but it WILL run yours. I went to a couple of other computers in my classroom and those ran the old macro just fine--even though they are running the Word 2003. My 2 computers are running the Student and Teacher Edition 2003--could that be making a difference?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macro doesn't work with 03 (office 2003)

    I cannot explain why the original code works on some machines with Word 2003 and not on others.

    If you want to apply the formatting to selected text only, simply remove or comment out the line

    Selection.HomeKey Unit:=wdStory

    in the macro I posted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •