Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Roderick O'Regan Roderick O'Regan is offline
external usenet poster
 
Posts: 19
Default Returning to Main Document

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
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Returning to Main Document

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
"Roderick O'Regan" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Roderick O'Regan Roderick O'Regan is offline
external usenet poster
 
Posts: 19
Default Returning to Main Document

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

On Fri, 28 Jul 2006 02:50:57 +0100, "Peter Jamieson"
wrote:

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
"Roderick O'Regan" wrote in message
.. .
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


  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Returning to Main Document

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
--
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

"Roderick O'Regan" wrote in message
...
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

On Fri, 28 Jul 2006 02:50:57 +0100, "Peter Jamieson"
wrote:

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
"Roderick O'Regan" wrote in message
. ..
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




  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Roderick O'Regan Roderick O'Regan is offline
external usenet poster
 
Posts: 19
Default Returning to Main Document

Thank you Doug.

Worked a treat!

Regards

Roderick


On Fri, 28 Jul 2006 19:25:49 +0200, "Doug Robbins - Word MVP"
wrote:

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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Once i have merged data into the main document how do i edit? mstimprince Mailmerge 1 July 18th 06 03:24 PM
Document Type Problem JoyceA Mailmerge 3 May 18th 06 11:19 AM
How to number only the Main Document, not first pages A. L. Microsoft Word Help 2 October 19th 05 03:38 AM
Data Files Not "Attached" to Mail Merge Main Document Denise H via OfficeKB.com Mailmerge 0 September 12th 05 08:15 PM
How to protect the main document in a mail merge process Antonio Ortiz Mailmerge 4 February 17th 05 09:05 PM


All times are GMT +1. The time now is 08:16 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"