Solved

How do you set the AttachedTemplate = "" ?

Posted on 2003-11-18
18
1,175 Views
Last Modified: 2007-12-19
We use a Word Template to automatically link to an Access database to create a mail merge document.  The problem that we’re having is that the Attached Template property links back to the original DOT file.  Every time we open a merged file based on the original template, the Access database is opened and the DOT file tries to create the auto-merge again.

Is there a way to automatically reset the property, AttachedTemplate = “Normal.dot” in the merged document?
0
Comment
Question by:DocZeuss
  • 10
  • 8
18 Comments
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9773509
0
 

Author Comment

by:DocZeuss
ID: 9780541
Dreamboat,

The code that you pointed me to doesn't seem to work in Word 2k.  I have also tried several other similar solutions:

http://beta.experts-exchange.com/Applications/MS_Office/Word/Q_20707834.html

http://support.microsoft.com/default.aspx?kbid=830561

This should be easy, but I haven't worked with programming code since DOS Basic!

I couldn't find any specific help in MS Knowledgebase for Word 2000?  Any other suggestions?
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9780608
Doesn't work? What occurs? Error messages?

You said:

>>Every time we open a merged file based on the original template, the Access database is opened and the DOT file tries to create the auto-merge again.

Are you sure you're not OPENING the DOT file? The code shouldn't be "copied over" to the merged document...

You should paste the code you're using now.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:DocZeuss
ID: 9783672
Let me be more precise:

1. We create a NEW Word file (Document1.doc) by double-clicking on "Template.DOT" which launches Access, prompts for a Job Number, and establishes mail merge links to our "data.mdb".

2. From "Document1.DOC" (created by the template file), we mail merge to a new file: "Form Letters1.doc".  We then save this file as "JobNumber.doc"

3. "JobNumber.doc" contains an AttachedDocument property that points to "Template.dot".  We want this link broken because every time you open "JobNumber.doc", the Template.DOT is opened, and then Access is launched again.

Is there a way to mail merge without creating a link back to the Template.dot?
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9783823
Oh, I see.

In your code, after the mail merge is performed....

    With ActiveDocument
        .AttachedTemplate = "C:\PathToNormalDot\Normal.dot"
    End With

Does that help?
I don't code.
I just steal and record.
0
 

Author Comment

by:DocZeuss
ID: 9788503
The code that you reccomended is exactly the same as my first attempt - I used the record a macro feature...

Interestingly, the macro works - BUT - you have run it twice!  The first time I run it, it opens the Control Tool Box toolbar and toggles design mode ON (opens a second one-bottom toolbar with no name) and halts.  I figured that the record a macro feature was the problem!

So why then does this code not work?  Do you think it has anything to do with the Template.DOT being a read-only file?  Maybe it tries to save it and stops the macro when it fails?  I'll try changing it.

I even tried to record a macro that runs the code above twice - no luck.  

This should be easy, but alas, I am stumped.  Microsoft has some elaborate code to loop trhough files in a directory to reset the AttachedTemplate proerty in KB articles I posted.  Those don't work either.  It may be a Word 2K issue?

I would understand if you give up this one.  Thanks for all your help.
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9788585
If you're getting design mode, you've got your macro security set to HIGH.
Open Word and go to Tools-Macro-Security and set it to low or medium.
THEN open your document.

Are you changing Template.dot?

What's the code you're using being CALLED from? Access or Word?

Sorry...I'm probably asking things you already answered...
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9788589
Oh....you say you're using 2000. Do you have other versions on your PC? Are you sure you're calling 2000 instead of 97 (for instance)?
0
 

Author Comment

by:DocZeuss
ID: 9788603
Follow-up: the code works fine in Word XP.  SO this may be a Word 2k issue.
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9788631
Did you check your 2k security settings...
0
 

Author Comment

by:DocZeuss
ID: 9788741
Duh.  I'm an idiot.  So much for the obvious.  Thanks for your help on this.  

One last Q, if I may be so bold: is there a way to make this code run automatically during the merge process?
0
 

Author Comment

by:DocZeuss
ID: 9788784
Also, because the Template.DOT is read-only, Word prompts the user to save chnages to it.  Any way to include a "no" response to this dialog box automatically in the code?

I need to make this invisble to my users.  Lowering macro security worries me too.  I may look at setting trusted macro sources...

If any Microsoft Word programmers are reviewing this, please add some functinality to allow the user to change the Template Path when creating mail merge documents!!!!  Argh!
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9788850
If you're in Word code, the line is something like this:

ActiveDocument.AttachedTemplate.Saved = True

If you do that, it thinks it's already saved and doesn't ask.
It does NOT save it.
0
 

Author Comment

by:DocZeuss
ID: 9791014
And you say you don't know how to code!  Nice job.  That worked.  Here's the final code:

    ActiveDocument.AttachedTemplate.Saved = True
   
    With ActiveDocument
        .UpdateStylesOnOpen = False
        .AttachedTemplate = ""
    End With
   
The result is that it defualts to the user's normal.dot

Now for the icing on the cake, how do you make it run automatically?  Or even better, when the user does a "save as..."?
0
 
LVL 22

Accepted Solution

by:
Dreamboat earned 125 total points
ID: 9792102
Hmmm...
Don't do it on save as, do it on close.

Open the VBE (Alt+F11)

Double-click ThisDocument on your TEMPLATE.
Choose the dropdowns in the code window for Document_Close

paste the code between the Sub/End sub that appears.

And I don't code. You might find some REAL interesting information in MY past questions!
smozgur helped me with this exact issue (the template asking to save changes) and some related issues in February of last year. Here's one:

http://www.experts-exchange.com/Applications/MS_Office/Q_20267391.html

So you see, I STOLE.
:)
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9792104
Oh, and I'll take chocolate buttercream, please.
0
 

Author Comment

by:DocZeuss
ID: 9795079
This worked nicely.  Thanks for all your help!
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 9796474
sure thing, doc!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question