Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Tonne Tonne is offline
external usenet poster
 
Posts: 2
Default Mail merge: reopening saved document prompts for SQL command twice

I am trying to merge a csv file:
Name;Address;Zipcode;City
My name;Where I live;DK-0000;Nearby
With a template containg bookmarks for Name, Address, ...

Everything works except for the two prompts for executing SQL commands when
the document is reopened. First a prompt for the real csv file and then a
prompt for a temporary csv file.
If I accept both the merge is repeatable.
If i print the query from VBA (ctrl-G print
activedocument.mailmerge.datasource.querystring) the result is a query on the
temporary file.

Here is the code (using 'generic' COM classes for everything):
COMappl = new COM(Word.Application);
COMdocuments = COMappl.documents();
COMdocument = COMdocuments.open(template); // variable holding
the template file
COMdocument.saveas(filename); // variable holding the saved doc
COMappl.visible(true);

COMmailmerge = COMdocument.mailmerge();
COMmailmerge.OpenDataSource(fileNameData,0,0,0,1); // variable
holding the datafile (csv)
COMmailmergefields = COMmailmerge.fields();

COMbookmarks = COMdocument.bookmarks();
COMbookmark = coMbookmarks.item('Name');
COMrange = coMbookmark.range();
COMmailmergefields.Add(COMrange,'Name'); // insert just one merge
field

COMmailmerge.Execute();
COMappl.Activate();

COMdocument.save();

Any ideas?
--
Tonne

 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
reopening document with cursor at same location as when saved?word 2007. Peter T. Daniels Microsoft Word Help 0 September 12th 09 11:45 PM
reopening document with cursor at same location as when saved? word2007. Llama Thumper Microsoft Word Help 1 September 12th 09 11:44 PM
mail merge without prompts carrol Mailmerge 1 November 8th 08 08:03 PM
Add-ins tab disappears after reopening a previously saved docx doc JohnM Microsoft Word Help 6 December 26th 06 10:47 AM
Mail Merge - Parameter prompts twice... TL Mailmerge 6 June 17th 05 02:58 PM


All times are GMT +1. The time now is 04:19 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"