Need some sort of AutoExec (maybe)

D

David

Apologies if there's a better group I could post to.

Word2000 + Win2000 or XP

I have a couple of mail merge documents that are recreations of some
forms from our company. Each contain some checkboxes. I employed the
method using AutoText/Macrobutton outlined by several posts I've seen to
toggle those checkboxes with my mouse -- with a couple of twists.

In order to use a single mouse click AND have the ability to use the
method on a file that I've created via 'Merge to new document', I have to
not only had to Attach the template to each of the two documents, but Add
the template to make it global and add some code to the template's
ThisDocument/Open routine to fire the template when I open either parent
or merged document and make single clicking work. Here are the routines
for that template as they stand.

ThisDocument:
Private Sub Document_Open()
AddIns("C:\data\word\CheckBox.dot").Installed = True
Options.ButtonFieldClicks = 1
End Sub

ChkBox Module Subs:
Sub CheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Checked Box").Insert
Where:=Selection.Range
End Sub

Sub UncheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Unchecked Box").Insert
Where:=Selection.Range
End Sub

Everything works exactly as desired, so I guess I shouldn't complain, but
there is one tiny cosmetic flaw. When I open the menu Insert | AutoText,
I see TWO entries each for 'Checked Box' and 'Unchecked Box'. Aargh!!!

I wrestled all weekend to adjust the file placement and code to both load
the template and fire the Document_Open routine so I could eliminate the
need to Attach the template to each file and still have the ability to
single click in all files and reduce the AutoText entries to a single
instance. No matter what I tried, there was always one piece of the
puzzle missing.

Any help? I want to have my cake and eat it too!!

One caveat: I want the template to remain in C:\Data\Word for two
reasons: 1) I backup this folder to two other machines daily and 2) since
the AddIns() line requires the full path, if I placed it in Word\Startup,
that's a looong path and unique for each machine.
 
P

Peter Hewett

Hi David

A bit of background info. When you create an output document using
MailMerge the document is attached to the SAME template as the MailMerge
MainDocument. However, any AuoNew or Document_New macros in the template
are disabled during the MailMerge as they could very well interfere with
the MailMerge process. Double check that your MailMerge MainDocument is
attached to your template! This obviously makes the code that sets the
attached template redundant.

I'm lost as to why you're using an Add-In!

I suspect that the reason you're seeing your "Checked Box" and "Unchecked
Box" AutoText entries twice is that you've added them to two different
templates! The Autocorrect>Autotext dialog defaults "Look in" to "All
active templates". When using AutoTexet be careful to select the template
you want to add the AutoText to before adding it! If this is the case
select the various templates to locate the erroneous AutoText entries and
then simply delete them.

HTH + Cheers - Peter
 
D

David

Peter Hewett wrote
A bit of background info. When you create an output document using
MailMerge the document is attached to the SAME template as the MailMerge
MainDocument. However, any AuoNew or Document_New macros in the template
are disabled during the MailMerge as they could very well interfere with
the MailMerge process. Double check that your MailMerge MainDocument is
attached to your template! This obviously makes the code that sets the
attached template redundant.

Thanks for jumping in, Peter. Not sure we're on the same page here as all
this is reletively new to me. I thought I pointed out in my original post
that the template is indeed attached. Don't know what you meant by 'makes
the code that sets the attached template redundant'. I included the entire
code in my OP.
I'm lost as to why you're using an Add-In!

Because if I don't, the output document checkboxes don't respond to mouse
clicks. I just sorta stumbled on to this 'fix'. Also the Document_Open line
in the template to set 'Installed = True' fails. This line is needed so I
don't have to manually go to Templates and Add-Ins and check the box.
Perhaps that's what you meant by 'makes the code that sets the attached
template redundant'.
I suspect that the reason you're seeing your "Checked Box" and "Unchecked
Box" AutoText entries twice is that you've added them to two different
templates!

I've checked and they are only available from this template. If I 'Remove'
the Add-In from Templates and Add-Ins and launch Word, they are not present
unless I open a file that has the same template attached.

I've concluded that the double entries stem from the fact that the template
is both attached AND an Add-In, but things don't work as desired unless
that's the case. At least I haven't found a way -- hence my post.
 
D

David

Peter,

Well, I'll be d*****!!.

I Remove(d) the template as an Add-In, commented out 'Installed = True'
line, ran the MailMerge and while mouse clicks didn't toggle checkboxes on
the output document at that point, if I saved, closed and reopened the
output document, no double AutoText entries and single mouseclick works!!
 
D

David

Peter,

Oops, spoke too soon. If I close and restart Word then load the saved
output document, boxes don't respond to mouse. Rats!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top