A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Mail Merge And access 2003



 
 
Thread Tools Display Modes
  #1  
Old March 29th, 2009, 05:03 PM posted to microsoft.public.word.mailmerge.fields
A
external usenet poster
 
Posts: 38
Default Mail Merge And access 2003

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


  #2  
Old April 1st, 2009, 09:59 AM posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
external usenet poster
 
Posts: 4,550
Default 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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:30 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.