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 / July 2006

Tip: Looking for answers? Try searching our database.

Returning to Main Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 27 Jul 2006 23:13 GMT
Here's the scenario...

The main document based on a template has been set up with the merge
fields and letter body text written.

A database has been opened.

A VBA procedure carries out the merge to a new document.

The merged document now takes the focus i.e. it becomes the active
document.

This is fine as I have to programatically carry out some actions in
this active document.

Is there a way, please,  to now programatically return to the main
merge document?

This main document might not have been saved so I cannot refer to it
by name.

Regards

Roderick
Peter Jamieson - 28 Jul 2006 02:50 GMT
> The main document based on a template has been set up with the merge
> fields and letter body text written.

As long as your code can make a reference to the document at this point, the
reference is still valid after the merge has been completed.

If your code cannot do that, then your code would ultimately have to guess,
I think.

Peter Jamieson
> Here's the scenario...
>
[quoted text clipped - 20 lines]
>
> Roderick
Roderick O'Regan - 28 Jul 2006 09:41 GMT
Thanks Peter for the tip.

Using the VBA help and your advice I've cobbled together something
like this below:
======================
Sub FindMergeMainDoc()
For Each docloop In Documents
With docloop
If .Bookmarks.Exists("MainMergeDoc") Then
Documents(docloop).MailMerge.EditMainDocument
Exit Sub
End If
End With
Next docloop
End Sub
=======================

It loops through all the open documents correctly and recognises the
bookmark in the Main Merge Document but it doesn't make it the active
document by bringing it to the fore.

Any ideas, please, where I'm going wrong?

Regards

Roderick

>> The main document based on a template has been set up with the merge
>> fields and letter body text written.
[quoted text clipped - 30 lines]
>>
>> Roderick
Doug Robbins - Word MVP - 28 Jul 2006 18:25 GMT
I assume that the VBA procedure that executes the merge is run when the mail
merge main document is the Active Document. In that case, in your present
VBA procedure, declare an object as a Document then at the beginning of the
code set that object to the then active document, then at the end of the
present code, issue a command to activate the document.
Sub whateveritisnow()
Dim mmmdoc as Document
Set mmmdoc = ActiveDocument

[rest of your code]

mmmdoc.Activate
End Sub
Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks Peter for the tip.
>
[quoted text clipped - 59 lines]
>>>
>>> Roderick
Roderick O'Regan - 28 Jul 2006 19:23 GMT
Thank you Doug.

Worked a treat!

Regards

Roderick

>I assume that the VBA procedure that executes the merge is run when the mail
>merge main document is the Active Document. In that case, in your present
[quoted text clipped - 9 lines]
>mmmdoc.Activate
>End Sub
 
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.