D
dixie
I create letters by mailmerging data from Microsoft Access into a .doc file
that I have set up to do this. When I do this, it is from inside an Access
mdb. The code basically looks like this:
Dim objword As Word.Document
Set objword = GetObject C:\letters\letter.doc, "Word.document")
objword.Application.Visible = True
objword.Mailmerge.Execute
objword.ActiveWindow.WindowState = wdWindowStateMaximize
Set objword = Nothing
The letter.doc file has a data source which points to a text file that
Access also sends out at the same time.
When this operates, two word files open individually, one is usually called
someting like forms1.doc and is the merged letter ready to either alter or
print. When that has been done and you close it, there is a 2nd word
document open - the original merge letter with the field in it. When I go
to close this, it asks me if I want to save it.
Now, what I want to happen is have only the finished letter open so it can
be printed, but I don't wish to have the actual merge letter open as some
users unfortunately do things like alter it or save it to another name or
generally interfere with it which they should not b able to do. Making it
read only is not a solution.
How do I overcome this difficulty? Is there some different code I can use
in the Access module that will not open the merge document at all, or open
it so it is not visible and then automatically close it before the merged
document is closed. I am a total novice at programming Word, but can you
program Word to close it down automatically. Or can I have these merge
letters as .dot templates and have only the merged file open - if so how do
I do that.
Largely, as you can see, my total lack of expertise in this area is showing
and I just know what I need to achieve, but how eludes me entirely.
Can anyone please help?
dixie
that I have set up to do this. When I do this, it is from inside an Access
mdb. The code basically looks like this:
Dim objword As Word.Document
Set objword = GetObject C:\letters\letter.doc, "Word.document")
objword.Application.Visible = True
objword.Mailmerge.Execute
objword.ActiveWindow.WindowState = wdWindowStateMaximize
Set objword = Nothing
The letter.doc file has a data source which points to a text file that
Access also sends out at the same time.
When this operates, two word files open individually, one is usually called
someting like forms1.doc and is the merged letter ready to either alter or
print. When that has been done and you close it, there is a 2nd word
document open - the original merge letter with the field in it. When I go
to close this, it asks me if I want to save it.
Now, what I want to happen is have only the finished letter open so it can
be printed, but I don't wish to have the actual merge letter open as some
users unfortunately do things like alter it or save it to another name or
generally interfere with it which they should not b able to do. Making it
read only is not a solution.
How do I overcome this difficulty? Is there some different code I can use
in the Access module that will not open the merge document at all, or open
it so it is not visible and then automatically close it before the merged
document is closed. I am a total novice at programming Word, but can you
program Word to close it down automatically. Or can I have these merge
letters as .dot templates and have only the merged file open - if so how do
I do that.
Largely, as you can see, my total lack of expertise in this area is showing
and I just know what I need to achieve, but how eludes me entirely.
Can anyone please help?
dixie