interop.word.mailmerge Normal.dot issue

I

Ian T

I have been developing a .NET word mailmerger (closely following
http://support.microsoft.com/kb/301656 as an example), and while I cannot see
anything in the code that would cause Normal.dot to be changed, the
"normal.dot has been changed..." dialog box comes up every time I close the
word application after doing a mail merge from the code.

Due to certain limitations, I cannot close the word application when I am
done with it, and any more mail merges open up new word applications, all of
which make changes to Normal.dot and then, when closed, complain that
Normal.dot is in use by another application.

Other limitations mean I have to use late binding to any word objects that I
create in my application.

My current idea is to have a static (shared) word application object that
gets used for each mailmerge. I believe this would get round the problem of
having multiple word applications trying to save changes to Normal.dot, but
this strikes me as only a work around to the real issue of why Normal.dot is
being changed in the first place.

Any suggestions?

Thanks,
Ian
 
C

Cindy M.

Hi =?Utf-8?B?SWFuIFQ=?=,

Why normal.dot is being changed could have any number of reasons - that kind of
thing is difficult to track down.

I'd just put a NormalTemplate.Saved = true statement at the end of my code to
tell Word there's nothing you want saved. That should suppress the dialog box if
nothing the user does at a later point affects Normal.dot

You don't show us how you work with the Word application, but I recommend you
consider using GetActiveObject to pick up any running instance, rather than
instantiating a new instance of the application every time.
I have been developing a .NET word mailmerger (closely following
http://support.microsoft.com/kb/301656 as an example), and while I cannot see
anything in the code that would cause Normal.dot to be changed, the
"normal.dot has been changed..." dialog box comes up every time I close the
word application after doing a mail merge from the code.

Due to certain limitations, I cannot close the word application when I am
done with it, and any more mail merges open up new word applications, all of
which make changes to Normal.dot and then, when closed, complain that
Normal.dot is in use by another application.

Other limitations mean I have to use late binding to any word objects that I
create in my application.

My current idea is to have a static (shared) word application object that
gets used for each mailmerge. I believe this would get round the problem of
having multiple word applications trying to save changes to Normal.dot, but
this strikes me as only a work around to the real issue of why Normal.dot is
being changed in the first place.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
F

Frank Wallis

Using a single instance is all very well, but if a document is then opened
for display in Internet Explorer or in an OleContainer it will hijack the
current running instance of Word. Any attempt to do a mail merge then gives
you the error 'This action is not available as the document is in another
application'. (This is because the OleContainer uses DocumentObjectModel not
MDI like the WordApplication). To have an application display documents in an
OleContainer and perform mail-merges you have to manage multiple instances of
Word. Ultimately you always seem to get normal.dot errors or the user will
get them if they have a copy of Word running as well.

I think Normal.dot gets changed because the MailMerge toolbar is displayed
when you do a mailmerge.

In Excel you can specify that no more connections are allowed to a running
instance. This is not available in Word as far as I know. If anyone has the
answer to my problems please do contact me...

Frank
(e-mail address removed)
 

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