Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mail Merge And access 2003
In the VBA editor, use Tools-References to make a reference to the
relevant Word object then use e.g. ' MMMD is "Mail Merge Main Document" Dim objMMMD As Word.Document Dim objWord As Word.Application Set objWord = CreateObject("Word.Application") Set objMMMD = objWord.Documents.Add("the full pathname of mytemp.dot") You should add error checking code, of course If the template is already connected to the correct data source, the new document based on it should also be connected, unless there is a problem with multi-user access in which case this approach will not work. It is probably better to ensure that the template is /not/ connected to the data source, and make the connection in code, e.g. if you are using Access VBA, try objMMMD.MailMerge.OpenDataSource _ Name:=CurrentDb.Name, _ SQLStatement:="SELECT * FROM mytable" However, a. you will need to provide your own query code b. that will only work with some types of database and e.g. if you have a workgroups security database you will need more. The basic code to merge to a new document is objMMMD.MailMerge.Destination = wdSendToNewDocument objMMMD.MailMerge.Execute You should be able to reference the new document using objWord.ActiveDocument You will need to close it, close objMMMD, then use objMMMD.Quit to close the instance of Word created by CreateObject. (2) how can prevent user from change mytemp.dot it self can't copy or edit the mytemp.dot content or save it (From word 2003) The easiest way to prevent the user from modifying the template is probably to make it read only in Windows for the relevant users. Peter Jamieson http://tips.pjmsn.me.uk a wrote: Dear friends I have a word template Mytemp.dot This is mail merge template connected to access.mdb What I want: (1) I want code to open the mytemp.dot (From Access 2003) But not mytemp.dot itself I want open a new word document based on mytemp.dot as like (merge to new document) so the user can't edit the mytemp.dot Again I want user open instance from mytemp.dot and the mytemp.dot connect to mydatabase and merge to a new word document (2) how can prevent user from change mytemp.dot it self can't copy or edit the mytemp.dot content or save it (From word 2003) Is this possible |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Mail Merge from Access 2003 to Word 2003 | Mailmerge | |||
Word 2003 and Access 2003 mail merge current record display issue | Mailmerge | |||
Automating Mail merge between Word 2003 and Access 2003 using VB.NET | Mailmerge | |||
Mail merge to a query in Access 2003 | Mailmerge | |||
Word 2003 and Access 2003 Mail Merge question | Microsoft Word Help |