View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Delete mailmerge database record

Let's assume you mean exactly what you say, i.e. "delete this record" in
the data source rather than than merely "exclude the record from the
merge." (If you just want to do that then you may be able to navigate to
the record and set its Included property to False).

I think the only option you have is to delete the record in the data
source itself without using the Word object model. How to do that would
be very dependent on the data source (for example, for a standard data
source created within Word 2002 or later, the data source would be an
Access/Jet .mdb file that could in theory be modified using ADO or DAO;
for a Word data source you would have to locate and delete the
paragraph/table row that contained the record, and so on).

That may or may not be possible while Word has the data source open,
depending on the data source, and the deletion of the record may or may
not be reflected immediately in the list of records to be merged.

Unfortunately you can't delete the record using the DataSource object.

Although it is just about possible that you might be able to program the
Dialog box that Word uses in its interface, you'd have to work out which
dialog it is. It may one of the large number that are not documented in
the wdWordDialog enumeration. For example, it could be Dialog 1373. Then
you'd have to be able to control it programmatically. If for example I
do Dialogs(1373).Display, it is unpopulated.

Again, some of the earlier dialog boxes have "verbs"/method names that
correspond to some of their properties/buttons, but the best you can do
is experiment with the newer dialogs.

Finally, in this case you would also have to get the dialog box to
display or select the record you needed to delete, and that's probably
either difficult or impossible.


Peter Jamieson

http://tips.pjmsn.me.uk

On 29/01/2010 11:04, Alan wrote:
In VBA I can move to the last record in a Word 2007 mailmerge datasource,
using
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
How can I delete this record ?