Mail merge and AutoNew

L

Lasse

Hi

I have a template that merges data from an Excel document and I need to
create a AutoNew macro in it.
I have created the AutoNew macro and it works fine if I open up the document
and run it through Visual Basic.
If I open up the template to create a new document it asks me to accept the
SQL command that gets the information from Excel and then it seems like it
forgets to run the AutoNew macro.

Have anyone seen this problem before and is there a way around it?
 
D

Doug Robbins - Word MVP

See the following Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

If you make the changes mentioned in that article, the SQL prompt will no
longer appear.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Lasse

Thanks for the reply, it worked perfectly.

Doug Robbins - Word MVP said:
See the following Knowledge Base article:

"Opening This Will Run the Following SQL Command" Message When You Open a
Word Document - 825765 at:

http://support.microsoft.com?kbid=825765

If you make the changes mentioned in that article, the SQL prompt will no
longer appear.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
L

Lasse

I take back my words :)

It removed the SQL command but it still doesn't run the AutoNew macro. I
have tried creating a simple AutoNew macro that just inserts a text string on
line 1 of the document.
I have tried deleting everything inside the document so that their wasn't
anything that could cause the problem.

My simply AutoNew looks like this:
Sub AutoNew()
Selection.InsertAfter ("Bookmark test")
End Sub
 
B

Bear

Lasse:

You've used very loose language when describing your actions, so I'm just
going to confirm that you only expect the AutoNew to run one time for any
document -- when that document is first created from a template. You can
either use the GUI and click File > New to create the document, or you can
open the template using the OS. Nothing else, particularly not opening the
document after it's been created, will run the AutoNew sub.

Bear
 
L

Lasse

I know how the AutoNew macro should work and that it's run only once when
creating a new document from the template.

But I have solved the problem. I copied everything from the original
template to a new template and created the AutoNew macro from the bottom and
then it worked.
I suspect that the original template was created in an earlier version of
Word and that was what caused the problem.
 
E

Ed

Hi Lasse,
I suspect that the original template was created in an earlier version of
Word and that was what caused the problem.

Or possibly it was created as a ".doc" and just renamed to be a ".dot"
(which doesn't make it a template).

Regards.

Ed
 

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