PDA

View Full Version : Insert AutoText Entry in Specific Font



clhare
01-24-2008, 11:33 AM
Is there a way to make sure that when AutoText is inserted into a document, it is always in the Arial font? Here's my code to insert the AutoText...I just can't figure out how to incorporate the font into it.

Sub InsertAutoText()

Dim aTemplate As Template
Dim myTemplate As Template

' Find the template among the loaded templates
For Each aTemplate In Templates
' Insert AutoText
If aTemplate = "My Template.dot" Then
Set myTemplate = aTemplate
myTemplate.AutoTextEntries("MyAutoText"). _
Insert where:=Selection.Range, RichText:=True
Exit For
End If
Next

End Sub

fumei
01-25-2008, 11:08 AM
An AutoText will be just as the AutoText is. If your AutoText is Arial...then your AutoText is Arial.

There may be an issues with the paragraph style, but the Autotext itself will be inserted exactly as it IS. If your AutoText is Arial...then your AutoText is Arial.

clhare
01-25-2008, 11:37 AM
I noticed that the AutoText entry I'm concerned with will take on whatever font applies to the paragraph the cursor is in--I think it's because my AutoText entry is not a complete paragraph. I tried adding a return to the AutoText and found that when I inserted it within TimesNewRoman text, it does stay Arial.

Is there any way to force the font to be Arial if the AutoText is not a complete paragraph?

fumei
01-25-2008, 12:47 PM
What version of Word are you using? I do not have this issue with 2002. I am attached a doc. Make sure you have Show/Hide on.

I put a Doc_Open instruction to go to a bookmark. It is right after some text - "cl2".

When you open the doc the selection will be at that bookmark. Press F3. This is will insert the AutoText "cl2", as that is the text just just before the Selection.

To repeat, everything is all set up. When you open the doc, just immediately press F3.

What do you see? The inserted AutoText, and it is Arial, even though the paragraph is Times Roman.

Let's go farther.

Go to a "empty" paragraph and type "cl1" - not cl2 - and press F3. Do nothing else for now.

Go to an "empty" paragraph and type "cl2" - not cl1 - and press F3.

Now look very carefully at the pilcrow - the paragraph marks.

cl1 is an AutoText that included the paragraph mark. Do you notice that the paragraph mark IS Arial?

cl2 is an AutoText, with almost identical text, that did NOT include the paragraph mark. Do you notice that the paragraph is not Arial, but the original Times Roman?