Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Before doing anything, have you applied the registry change in the
following article: http://support.microsoft.com/kb/825765 Also, which version of word are you using? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Tonne wrote: 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? |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Yes. I should have mentioned that, sorry.
Adding the registry key will solve the symptoms; I just wondered if I did something wrong. This morning I did a manual mail merge, saved the main document after the merge and the exact same prompt for SQL statement twice when reopening! A flaw in Office 2007, perhaps? I can live with the registry fix as I can apply it from my program before doing the mail merge. -- Henrik Tonnesen attentive as "Peter Jamieson" wrote: Before doing anything, have you applied the registry change in the following article: http://support.microsoft.com/kb/825765 Also, which version of word are you using? Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Tonne wrote: 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? |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I just wondered if I did something wrong.
I don't think so. A flaw in Office 2007, perhaps? Word 2007 copies some types of data source to a local folder. It's part of some security change. Unfortunately it is very difficult to tell in what circumstance Word will do this, but I think it is in essence when Word thinks it is opening a "field type" data source and it thinks it is on the Internet. So Word then has to deal with the fact that you specify one file name and it ends up dealing with another. FWIW I take the view that things that do not work for inexplicable reasons are actually less secure than things that work the way you asked them to, but there you go. Peter Jamieson http://tips.pjmsn.me.uk Visit Londinium at http://www.ralphwatson.tv Tonne wrote: Yes. I should have mentioned that, sorry. Adding the registry key will solve the symptoms; I just wondered if I did something wrong. This morning I did a manual mail merge, saved the main document after the merge and the exact same prompt for SQL statement twice when reopening! A flaw in Office 2007, perhaps? I can live with the registry fix as I can apply it from my program before doing the mail merge. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
reopening document with cursor at same location as when saved?word 2007. | Microsoft Word Help | |||
reopening document with cursor at same location as when saved? word2007. | Microsoft Word Help | |||
mail merge without prompts | Mailmerge | |||
Add-ins tab disappears after reopening a previously saved docx doc | Microsoft Word Help | |||
Mail Merge - Parameter prompts twice... | Mailmerge |