Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

word macro to add autotext entry to STARTUP\Personal.dot

Status
Not open for further replies.

dotobi

Technical User
Mar 9, 2004
229
HK
I want to use a STARTUP\Personal.dot template for all users to store their AutoText extries.

Therefore, I would need to force word to add new AutoText entries to the Personal.dot file when the user highlights the text and presses Alt+F3.

The Best way I can think to do this is to create a macro to Mimick the "Create AutoText" function, but to save it to the personal.dot file. Then I could assign Alt+F3 to this new macro.

Any ideas on the code for this macro? or... a better way to force word to Add AutoText to Personal.dot?

Thanks

Kev
 
No, that is how you do it. You force normal.dot to create the AutoText into the global template by overwriting the normal command to create an AutoText entry. Here is how.

Assumption: you DO have a global template (Personal.dot) in the Startup folder. That is, it WILL be loaded. Put the following into Normal.dot. You need to get the Name, so that is picked up by an Inputbox.
Code:
Sub CreateAutoText()
[COLOR=red]' Overrides Alt+F3
' make a template object of the global Personal.dot[/color red]
Dim myTemplate As Word.Template
Set myTemplate = Application.Templates("C:\Program Files\Microsoft Office\Office10\Startup\Personal.dot")
[COLOR=red]' make sure there IS a Selection[/color red]
If Len(Selection.Text) > 1 Then
[COLOR=red]' add it to Personal.dot NOT normal.dot
' using the Selection Range, and
' the user input name[/color red]
    myTemplate.AutoTextEntries.Add _
        Range:=Selection.Range, Name:=InputBox("Type the name you wish to use for this AutoText")
End If
Set myTemplate = Nothing
End Sub
The AutoText entry will be in Personal.dot NOT normal.dot.

Gerry
My paintings and sculpture
 
I should add, fortunately the default lookup for InsertAutoText (F3)is "all available templates". Otherwise you would have to write a redirection for the InsertAutoText command as well. So as long as your global is loaded, it should work.

Gerry
My paintings and sculpture
 
I would like users to have their own personal.dot's. So, Can I use:
Code:
Set myTemplate = Application.Templates("C:\Documents and Settings\[COLOR=red]%USERNAME%[/color]\Application Data\Microsoft\Word\STARTUP\Personal.dot")
? (or an alternative to %USERNAME%?)

Thanks
 
Are you pushing a standard normal.dot to everyone?

Actually, I don't know if you could use %username%. Try it.

As you may have noticed, I do not put the global template into a username path folder. It is in Program Files/etc etc /Startup folder - independent on user. But specific to the machine.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top