Re: How to identify current format data for use in macros? by Klaus
Klaus
Wed Aug 01 22:12:17 CDT 2007
"dnatasha" wrote:
>I have macros for inserting specific characters, but in some cases I need
>to
> use a font that is different from the main body of the text. I want to
> make
> the macro universal, so that no matter what the original font is, the
> macro
> will identify that font, then insert the symbol which may specify a
> different
> font, and then after the insert reset the font back to the original.
> Stated
> otherwise I need to know how to identify the default font type, so I can
> return to it.
Hi,
First, I'd try to avoid symbol fonts as much as possible. The fonts most
Word documents use, Arial and Times New Roman, contain over 1600 characters
and symbols.
If you do need to insert symbols, the font of the preceeding and following
text isn't changed.
You could use something like
Selection.Collapse(wdCollapseEnd)
Selection.InsertSymbol _
Font:="Symbol", _
CharacterNumber:=97, _
Unicode:=True
(in this case an alpha, code 97, from the Symbol font).
Another good option would be a symbol field.
Selection.Collapse(wdCollapseEnd)
ActiveDocument.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldSymbol, _
Text:="97 \f ""Symbol""", _
PreserveFormatting:=False
Both the methods above are good because they make sure you don't
accidentally change the font later on -- say by (re)applying a style, or
resetting the formatting with Ctrl+Spacebar = ResetFont.
If you'd just insert the character with .TypeText or .InsertAfter and apply
the symbol font, that wouldn't be the case.
Regards,
Klaus