Font Switching Macro?
From: Greg (anonymous_at_discussions.microsoft.com)
Date: 07/26/04
- Next message: Lerxst: "Font Switching Macro?"
- Previous message: umpty: "Programatically Creating a Hyperlink"
- In reply to: Lerxst: "Font Switching Macro?"
- Next in thread: Lerxst: "Font Switching Macro?"
- Reply: Lerxst: "Font Switching Macro?"
- Messages sorted by: [ date ] [ thread ]
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.
>>.
>>
>.
>
- Next message: Lerxst: "Font Switching Macro?"
- Previous message: umpty: "Programatically Creating a Hyperlink"
- In reply to: Lerxst: "Font Switching Macro?"
- Next in thread: Lerxst: "Font Switching Macro?"
- Reply: Lerxst: "Font Switching Macro?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|