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 / June 2007

Tip: Looking for answers? Try searching our database.

Mail merge and AutoNew

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lasse - 25 Jun 2007 10:06 GMT
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?
Doug Robbins - Word MVP - 25 Jun 2007 10:10 GMT
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.

Signature

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

> Hi
>
[quoted text clipped - 9 lines]
>
> Have anyone seen this problem before and is there a way around it?
Lasse - 25 Jun 2007 13:16 GMT
Thanks for the reply, it worked perfectly.

> See the following Knowledge Base article:
>
[quoted text clipped - 19 lines]
> >
> > Have anyone seen this problem before and is there a way around it?
Lasse - 25 Jun 2007 15:37 GMT
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

> See the following Knowledge Base article:
>
[quoted text clipped - 19 lines]
> >
> > Have anyone seen this problem before and is there a way around it?
Bear - 25 Jun 2007 16:51 GMT
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
Signature

Windows XP, Word 2000

Lasse - 26 Jun 2007 07:21 GMT
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.

> Lasse:
>
[quoted text clipped - 6 lines]
>
> Bear
Ed - 26 Jun 2007 18:30 GMT
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

> I know how the AutoNew macro should work and that it's run only once when
> creating a new document from the template.
[quoted text clipped - 15 lines]
> >
> > Bear
 
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.