Disable Macro

A

Andrew Duncan

Hi,

I've been working on the following macro:

Sub AutoOpen()
Dim doc as Word.Document

Set doc = ActiveDocument
doc.MailMerge.Execute
doc.Close wdDoNotSaveChanges
End Sub

This peforms a mail merge when the document is opened to
a new document and closes the original. This happens to
all documents now and I cannot edit the original
document. Does anyone know how to turn this off
temporarily so I can make changes to the original
document?

Many thanks,
Andrew
 
J

Jay Freedman

Hi, Andrew,

Hold down the Shift key while opening the document. This suppresses all
Auto... macros.

Another thing... from your comment that "this happens to all documents now"
I assume the AutoOpen macro is in your Normal.dot template. It should be
only in a separate template used only for mail merge documents.
 
G

Guest

Thanks very much Jay, that's just what I was looking for.
I'd realised that the AutoOpen macro was happening for
all documents - do you know how to set it so that it only
works for mail merge documents? I have about 25 existing
mail merge documents (.doc files) that I regularly use
for mail merging with my database.

Many thanks,
Andrew
 
H

Howard Kaikow

If needed only for particular documents, there a number of possibilities,
including the following:

1. Crate a toolbar button or menu item or keyboard shortcut to execute the
macro at your pleasure.

2. If the documents to be merged are known in advance, modify the AutoOpen
macro to check whether a document is amongst that set.

3. If the documents to be merged are attached only to a specific template,
then pit AutoOPen in each of those templates and not in the Normal template.
 

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