1
Answer

C# .NET Mail Merge Problem with Word's Normal.dot template

Ask a question
Frank

Frank

15y
8.2k
1

Hi folks -

This is my first post, though I've gained some valuable info here in the past using the Search facility.

I am having a problem with a Word-based mail merge in a C# Windows form application. The problem has to do with the Normal.dot template.

 

At a high level, my app copies a Word dot template file (not named Normal) to a temp directory, and performs a merge with a data file. If I wanted to save the newly-merged doc file at this point and then close Word entirely there would be no problem.

 

But, I need to keep the newly-created merged content doc file open. Right now, here’s what happens:

 

The merge takes place, my app ends, and you are left viewing the new doc file in Word.

 

At this point, you can either “Save As” with this new doc then exit Word, or just exit Word without saving the new doc – the following occurs either way.

 

A message box appears: “The file is in use by another application or user. (C:\Documents and Settings\...\Normal.dot)”.

 

Click OK (the only choice) and a “Save As” pane appears referring to Normal.dot.

 

Click on “Cancel” (because I don’t want to save Normal.dot) and you’re looking at a empty instance of Word.

 

Click the red X or choose File/Exit and a message box appears: “Changes have been made that affect the global template, Normal.dot. Do you want to save these changes?”

 

Select “No” and Word finally closes.

 

Again, if I just wanted to have the app save my new doc then shut down Word this would be easy. But how can I kill whatever has attached itself to Normal.dot while leaving my new doc open in Word? I don’t want the users to have to deal with making choices about the Normal.dot file. Again, the dot I use in the merge is not Normal.dot…

 

Thanks for any insight about this problem…

Frank


Answers (1)