Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Save Autotext entry to User.dot

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sammy - 05 Dec 2007 16:04 GMT
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.
Jay Freedman - 05 Dec 2007 17:00 GMT
There's similar code in the AutoTextLoader2.dot template that you can
download from http://jay-freedman.info, 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.

Signature

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

> Hello,
>
[quoted text clipped - 38 lines]
>
> ANY IDEAS?  THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
Sammy - 05 Dec 2007 17:51 GMT
THANKS JAY I WILL GIVE THIS A TRY.

> There's similar code in the AutoTextLoader2.dot template that you can
> download from http://jay-freedman.info, and you're welcome to use or adapt
[quoted text clipped - 47 lines]
> >
> > ANY IDEAS?  THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
Sammy - 05 Dec 2007 18:15 GMT
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

> Hello,
>
[quoted text clipped - 38 lines]
>
> ANY IDEAS?  THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
Jay Freedman - 05 Dec 2007 19:14 GMT
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.

Signature

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

> 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
[quoted text clipped - 44 lines]
>>
>> ANY IDEAS?  THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
Sammy - 07 Dec 2007 16:38 GMT
Okay thanks, I will give it a try.

> The AutoTextLoader macro cannot be "used to accomplish this". You can pick
> out the pieces that apply to your circumstances -- specifically, the parts
[quoted text clipped - 53 lines]
> >>
> >> ANY IDEAS?  THANK YOU FOR YOUR ASSISTANCE AND HAPPY HOLIDAYS.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.