Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / November 2006

Tip: Looking for answers? Try searching our database.

Open copy of merge doc, close original without saving

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Todd K. - 14 Nov 2006 15:22 GMT
I found the code to do this on another area of this newsgroup, but it doesn't
appear to work.  I have entered the following in a Word module:
Public Sub DoMailMerge()

   Dim DocName
   DocName = ActiveDocument.Name
   'Do mailmerge
   With ActiveDocument.MailMerge
       .Destination = wdSendToNewDocument
       .Execute
   End With
   'Close mailmerge document
   Windows(DocName).Close wdDoNotSaveChanges
   
End Sub

Then in the Document_Open property of my mailmerge document, I wrote
DoMailMerge.  But when I open the document (from Access), it just opens the
orginal merge document.  No errors, no debug, no copy that I can see.
Peter Jamieson - 16 Nov 2006 10:48 GMT
The first problem is that when you automate Word, it doesn't necessarily
open its data source - see

http://support.microsoft.com/kb/825765/en-us

Peter Jamieson
>I found the code to do this on another area of this newsgroup, but it
>doesn't
[quoted text clipped - 17 lines]
> the
> orginal merge document.  No errors, no debug, no copy that I can see.
Todd K. - 16 Nov 2006 14:11 GMT
I have heard of this issue before, and I think at this point I am fine with
having the users click <Yes> at the prompt for letting the SQL run.  Once we
click <Yes> though, shouldn't it run the code?

> The first problem is that when you automate Word, it doesn't necessarily
> open its data source - see
[quoted text clipped - 23 lines]
> > the
> > orginal merge document.  No errors, no debug, no copy that I can see.
Peter Jamieson - 16 Nov 2006 18:54 GMT
Well, i just tried something like this and the SQL registry setting didn't
obviously make a difference. However, what does happen depends on the code
you're running in Access.

What happened on my system was that when I opened the document (from an
Access VBA routine), Word did open and execute the merge. Then your code
closes the mail merge main document. It's helpful to make Word visible
before opening the document so you can see what's happening. If you don't do
that, you won't see anything.

Anyway, after the macro runs, the result document is there in Word. However,
if you are running from an Access module that sets the Word object to
nothing or quits Word, chances are you will either be left with invisible
WINWORD processes in your Windows task list, or the output document will
just be deleted.

Peter Jamieson

>I have heard of this issue before, and I think at this point I am fine with
> having the users click <Yes> at the prompt for letting the SQL run.  Once
[quoted text clipped - 28 lines]
>> > the
>> > orginal merge document.  No errors, no debug, no copy that I can see.
Todd K. - 16 Nov 2006 19:08 GMT
The code I run in Access simply does a hyperlink to open up the Word document
(Application.FollowHyperlink "I:\Applications\Databases\Amendment_Ren.doc"),
it's the code below in the Word document that is supposed to open up a copy
and close the original.  I guess I have two  questions:

1) If I adjust the SQL registry setting, will it allow the code below to
operate in the Word document?
2) If not, what else could it be?

> Well, i just tried something like this and the SQL registry setting didn't
> obviously make a difference. However, what does happen depends on the code
[quoted text clipped - 46 lines]
> >> > the
> >> > orginal merge document.  No errors, no debug, no copy that I can see.
Peter Jamieson - 16 Nov 2006 23:45 GMT
OK, when I do it that way, the main thing that stops anything from happening
is when I set macro Security in Word to High, i.e. so Word simply won't run
the macros unless the conditions are right.

Peter Jamieson

> The code I run in Access simply does a hyperlink to open up the Word
> document
[quoted text clipped - 67 lines]
>> >> > orginal merge document.  No errors, no debug, no copy that I can
>> >> > see.
Todd K. - 17 Nov 2006 13:18 GMT
Jamieson, you're a genius!  I hadn't even thought about reducing security in
Word, once I did, the code worked perfectly.

Thanks!

> OK, when I do it that way, the main thing that stops anything from happening
> is when I set macro Security in Word to High, i.e. so Word simply won't run
[quoted text clipped - 73 lines]
> >> >> > orginal merge document.  No errors, no debug, no copy that I can
> >> >> > see.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.