Activating a document

M

markl59

Hi,
I'm building a macro that buils and opens a new document from a User
Form contained in the current document. When I've built the new
document I want to close the current one and activate (or bring to the
front) the new one. However if I already have documents open, I
activate the new one but then the code to unload the old one appears to
reactivate it. Then when it does unload, focus goes to the first open
document., not my current one. Is there a way I can activate the new
doc without 'losing focus' when further code runs in the old one
(though it is only a Close ).
Thanks for any ideas,
Mark
 
J

Jezebel

1. The code shouldn't be in any document. It should be in a global template
or an add-in. That way the code is not affected by the documents you open or
close.

2. When you create the document, get a reference to it; then active that
reference --

Dim pDoc as Word.Document
set pDoc = Documents.Add(Template:="...)
:
pDoc.Activate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top