Font Switching Macro?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Greg (anonymous_at_discussions.microsoft.com)
Date: 07/26/04


Date: Mon, 26 Jul 2004 11:24:11 -0700

Lerxst,

Your solution definately looks more polished than the one
I cobbled together :-). I found it relatively easy to use
a docvariable to store the data, the problem I encountered
was if the user first applied the macro while using the
symblol font. The result was a ugly error code. With the
help of Dave Lett I found a way around this and it seems
to work well. At first I thought that you had solved that
issue without even trying. On further study I realized
that the value in the ini file is saved from document to
document. I noticed if the value is say TNR, the user
starts a new file with Courier as the default font,
manually applies symbol, then toggles, the toggle will go
to TNR. Just a nit I know. I posted an improvement of
the code Chad mentions in the VBA general ng. Have a look
if you are interested.
>-----Original Message-----
>I suspect you mean you need to toggle back and forth
>between the two fonts. In this case storing to a variable
>won't work because the variable will lose its value once
>the script is done executing. Instead write it out using
>the system.privateprofilestring method.
>
>Sub ToggleSymbolFont
>If selection.font.name <> "Symbol" then
>System.PrivateProfileString
>("ToggleSymbolFont","Memory","OriginalFont")
>=selection.font.name
>selection.font.name="Symbol"
>Else
>selection.font.name=System.PrivateProfileString
>("ToggleSymbolFont","Memory","OriginalFont")
>End Sub
>
>>-----Original Message-----
>>I'm very new at writing macros for Word and am hoping
>for some help.
>>
>>I need to write a macro that will allow me to switch
>between my current font
>>and the Symbol font with one keystroke. I don't know
>how to store the
>>name of the current font as a variable. Following is
>what I believe would be
>>the simplest script, but I don't know how to make it
>work with VBA.
>>
>>If Selection.Font.Name is not = "Symbol"
>>Then
>> OldFont=.Selection.Font.Name
>> .Selection.Font.Name="Symbol"
>>Else
>> .Selection.Font.Name=OldFont
>>End If
>>
>>Thanks for your help.
>>.
>>
>.
>



Relevant Pages

  • Help with Oject Deleted Error
    ... Yesterday I was helping another user crate a macro to ... toggle from any font to "symbol" font and then toggle back ... message with a more pleasing message something like "The ...
    (microsoft.public.word.vba.general)
  • Re: Mail Merge Label Macro w/Russian Text
    ... When I simply run a mail merge in word without recording it as a macro, ... I modify the macro to prompt the user for an excel file to read from ... and font in word appear to be working properly. ... does not support the Unicode Cyrillic characters. ...
    (microsoft.public.word.mailmerge.fields)
  • Re: inserting a tick
    ... look in the Wingdings font. ... A CheckIt macro and an UncheckIt macro. ... Checked Box and Unchecked Box AutoText entries (these are just Wingdings ... EQ field," but you can get the same effect by applying a border ...
    (microsoft.public.word.docmanagement)
  • RE: Repetive Formatting/Creating a Toolbar button
    ... and what is the scrip for the macro that will make font Arial,Bold, and have ... I work on different worksheets all of the time and have to choose format (on ... different cells specific font withing the cell). ...
    (microsoft.public.excel.misc)
  • RE: Specify a font from a formula?
    ... to resort to a macro, as it just opens up other complications for the ... The actual font I'm using is a specialty font (not Wingings; ... compact the width of the cell) but I've managed to work around it. ... character and it converts it to Wingdings and then ...
    (microsoft.public.excel.worksheet.functions)