How to designate two open docs as different objects?

E

Ed from AZ

I have two documents open. It would be a royal pain to have to browse
for them; I just have the folders open and open the two docs needed.

I need to desginate one document as "doc1" and the other as
"doc2" (Both are Dim'd As Document objects.) I tried a bit with a
UserForm, but culdn't get it to work. So in my code, I Stop the code,
which lets me click in a doc, then F5 in the VBE and Stop again to
click in the second doc, then F5 again to run.

MsgBox "Click in the first document"
Stop
Set doc1 = ActiveDocument
Set rng1 = doc1.Range(Selection.Range.Start, doc1.Content.End)

MsgBox "Click in the second document"
Stop
Set doc2 = ActiveDocument
Set rng2 = doc2.Range(Selection.Range.Start, doc2.Content.End)

Is there an easier, more seamless way to do this?

Ed
 
F

fumei via OfficeKB.com

Well yes. You can set a document object to an item in the Documents
collection, not just to the ActiveDocument. I often set a Document object to
a document that is not active. You can make and use Ranges....whatever.

Except, I am re-reading your post. It is not that clear. Are you asking
about clicking in a dialog. I am not following: "I just have the folders
open and open the two docs needed"

Please explain more clearly, as I notice you are using Selection as well.

doc1.Range(Selection.Range.Start, doc1.Content.End)

This seems odd to me.
 
E

Ed from AZ

Yeah, it's a thrown-together macro. I have an entire set of docs that
I have to compare, paragraph by paragraph. So I open the two docs
and then fire off the macro. Besides setting the doc objects, the
Selection was to enable me to click in the doc at a certain point and
set the range to look in from the insertion point to the end.

Ed
 

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