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 / March 2005

Tip: Looking for answers? Try searching our database.

Autotext and Word VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben M - 09 Mar 2005 07:38 GMT
Hi,

I have previously created a template that has several checkboxes.
When selecting a checkbox, that triggers an autotext entry to be
inserted into the document.  This works great!

However... I need to expand this further now, and this is where I face
a problem or two.  In my new design, I need a different set of check
boxes to display, and this should be accomplished by selecting one of
two option buttons.

When (for example) option button one is selected, an autotext entry
should be inserted.  This entry should display the appropriate set of
checkboxes.  Obviously when checking a check box, an event should
occur (as it did previously).

The problem I face is the autotext entry with the checkboxes does not
function, as it's trying to reference code that does not exist in the
*document*.  The code actually exists in the *template*.

How can I make the document look at the template for the code?  It's
also interesting to note that as soon as I select one of the option
buttons and display the new autotext entry with checkboxes, all my
other contols no longer work.  It seem that my link to the template is
severed in some way.

Hope you can help me  :)

Thanks,
Ben (Frustrated)
Chuck - 09 Mar 2005 13:13 GMT
Assuming that you're working with macrobuttons to show checkboxes etc, the
underlying macros would need to be stored in an add in and that add in would
need to be loaded.  Is the template that contains your macrobutton in your
Startup folder?

> Hi,
>
[quoted text clipped - 26 lines]
> Thanks,
> Ben (Frustrated)
Claudia - 09 Mar 2005 17:13 GMT
I'm having a similar problem as the person originally posting. I've created a
global template that stores macros and AutoText entries for use by all users
in our office. I want the user to be able to run a macro that inserts the
AutoText but I'm getting a Run Time error because it's looking for AutoText
in the document when it the AutoText is actually stored in the global
template. The advantage to writing a macro to insert the AutoText is I can
insert Input Boxes into the inserted AutoText for boilerplate automation.
This, of course, works swell if I have the template open. But not when I
simply add the template as a global.

Like the person posting this question, I need to know how to get it to look
for AutoText in the *template*. The template is added using "Templates and
Add-Ins."

Claudia

> Assuming that you're working with macrobuttons to show checkboxes etc, the
> underlying macros would need to be stored in an add in and that add in would
> need to be loaded.  Is the template that contains your macrobutton in your
> Startup folder?
Chuck - 09 Mar 2005 17:23 GMT
Try this, where "AutoText.dot" is the template where you've stored your
autotext entry and AUTOTEXT_PATH is where AutoText.dot is located:

   Dim tmpTemplate As Template
   
   Set tmpTemplate = Templates("C:\AUTOTEXT_PATH\AutoText.dot")
   
   tmpTemplate.AutoTextEntries("YourAutoTextEntryName").Insert _
   Where:=Selection.Range
   
   Set tmpTemplate = Nothing

> I'm having a similar problem as the person originally posting. I've created a
> global template that stores macros and AutoText entries for use by all users
[quoted text clipped - 16 lines]
> > need to be loaded.  Is the template that contains your macrobutton in your
> > Startup folder?
Chuck - 09 Mar 2005 17:25 GMT
PS -- your autotext template may still need to be loaded as a global
template.  You can do that as follows, I do it in Normal.dot AutoExec macro
so it's available from the get go:

   If Dir$("C:\AUTOTEXT_PATH\AutoText.Dot") <> "" Then
       'load add in
       AddIns.Add _
           FileName:="C:\AUTOTEXT_PATH\AutoText.Dot", _
           Install:=True
   End If

> I'm having a similar problem as the person originally posting. I've created a
> global template that stores macros and AutoText entries for use by all users
[quoted text clipped - 16 lines]
> > need to be loaded.  Is the template that contains your macrobutton in your
> > Startup folder?
Claudia - 09 Mar 2005 23:29 GMT
> PS -- your autotext template may still need to be loaded as a global template. <

So, it's not sufficient to have the global template loaded from Templates
and Add-Ins? Here's the macro as I've rewritten it. It's not working - still
getting a Run Time error. If you could tell me where I have it wrong, that
would be wonderful (this is run with the global template loaded).

Sub TestAutoTextInsert()
'
' TestAutoTextInsert Macro
' Macro recorded 3/9/2005 by Claudia Carvalho
'
Dim tmpTemplate As Template

   Set tmpTemplate = Templates("V:\Forms_Word\OFFICE\Macros.dot")
   
   tmpTemplate.AutoTextEntries("Intro Rogs Answer").Insert _
       Where:=Selection.Range
   
   Set tmpTemplate = Nothing

End Sub
Chuck - 10 Mar 2005 11:29 GMT
What specific run time error are you getting?  "5941 - The requested member
of the collection does not exist"?  Are you sure your autotext entry name is
spelled correctly?  Are you sure the global template is actually loaded?

It should work whether you load the global template manually or through code.

Chuck

> > PS -- your autotext template may still need to be loaded as a global template. <
>
[quoted text clipped - 18 lines]
>
> End Sub
 
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.