Save Autotext entry to User.dot

Save Autotext entry to User.dot

Post by U2FtbX » Fri, 07 Dec 2007 01:04:09


Hello,

I'm trying to create a macro that forces autotext entries to be saved in a
special template called User.dot instead of Normal.dot. I have the macro
tied to Alt+F3, this is how the users will save their autotext. Here's what
I have so far, the message boxes work but it still won't save the autotext
entry in the User.dot:

Sub UserAutoText()

Dim SelectText As Range
Dim AutoTextEntry As AutoTextEntry
Dim myTemplate As Template


Application.ScreenUpdating = False
On Error GoTo Quit
Set SelectText = Selection.Range
If SelectText = "" Then
MsgBox ("You Must Select Text First"), vbOKOnly + vbCritical, "Save
AutoText Entry"
Else: GoTo CreateAutoText
End If
GoTo Quit
CreateAutoText:
AutoTextEntry = InputBox("Word will save an AutoText entry from the current
selection in your User.dot. Please name your AutoText entry and then press
Enter.", Title:="AutoText Entry")
If AutoTextEntry = "" Then GoTo Quit
Dialogs(wdDialogFileOpen).Show

Documents.Open FileName:="C:\Program Files\Microsoft
Office\Office10\Startup\User.dot"
Set myTemplate = ActiveDocument.AttachedTemplate
myTemplate.AutoTextEntries.Add Name:=AutoTextEntry, _
Range:=SelectText
ActiveDocument.Save
ActiveDocument.Close
Quit:
Application.ScreenUpdating = True
End Sub

ANY IDEAS? THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
 
 
 

Save Autotext entry to User.dot

Post by Jay Freedm » Fri, 07 Dec 2007 02:00:16

There's similar code in the AutoTextLoader2.dot template that you can
download from http://www.yqcomputer.com/ , and you're welcome to use or adapt
any part of that.

The main difference seems to be that you're opening User.dot and then using
it as its own AttachedTemplate. The AutoTextLoader macro instead opens a
regular document _based on_ the template and then uses its AttachedTemplate
to store the entries.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.yqcomputer.com/
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

 
 
 

Save Autotext entry to User.dot

Post by U2FtbX » Fri, 07 Dec 2007 02:51:02

THANKS JAY I WILL GIVE THIS A TRY.
 
 
 

Save Autotext entry to User.dot

Post by U2FtbX » Fri, 07 Dec 2007 03:15:03

I'm not sure how I can use this on the fly without a table. I need this to
work whenever a user creates an autotext entry. So with the User.dot
template loaded, anytime a user presses Alt+F3 and gives a name for the
selected text, the new entry gets saved in the User.dot. Can your macro be
used to accomplish this? Thanks again
 
 
 

Save Autotext entry to User.dot

Post by Jay Freedm » Fri, 07 Dec 2007 04:14:01

The AutoTextLoader macro cannot be "used to accomplish this". You can pick
out the pieces that apply to your circumstances -- specifically, the parts
about getting access to the desired template and saving the entry in it --
and throw away the rest.

In your case, the AutoTextEntries.Add command uses Range:=SelectText to
specify what to save in the entry. That's all you need, so you can ignore
the "table" part of AutoTextLoader.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://www.yqcomputer.com/
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
 
 

Save Autotext entry to User.dot

Post by U2FtbX » Sun, 09 Dec 2007 01:38:00

Okay thanks, I will give it a try.