Switch between document and close

O

Outatym

I have a userform that opens on Document A. Depending on which button on it
the user selects, it will either open up Document B or Document C. Both of
these documents also have userforms that fire when the documents are opened.

Private Sub CmdCommRun_Click()
OpenForm.Hide
Documents.Open FileName:="T:\Proposal\DocumentB.doc"
End Sub

and

Private Sub CmdTrkgRun_Click()
OpenForm.Hide
Documents.Open FileName:="T:\Proposal\DocumentC.doc"
End Sub

This works fine, the problem I am having is that I need to close Document A
AFTER the other document has already opened.

I can't seem to get the ActiveDocument property to work right.

What code would be needed? Would it be on the DOC B & C's userform's
initialize or activate properties? Would I need to set up global variables
and test for them?

Any help would be appreciated.
 
G

Graham Mayor

How about

Private Sub CmdCommRun_Click()
Set adoc = ActiveDocument
Unload Me
Documents.Open FileName:="T:\Proposal\DocumentB.doc"
adoc.Close wdDoNotSaveChanges
End Sub



--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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