making a doc the current top/active one

A

Andrew Kennard

Hi all

I am automating Word 2003

I've attached to and existing word instance got the documents collection.

Looked through the document objects in it and found the one I want to
"activate" but I cant seem to get it to be the top level window

ie I have 3 word docs open Doc1, Doc2, Doc3. Doc1 is on top and Doc3 is on
the bottom

After my search I've found that I want Doc2 to be the top/active document

I've tried Calling the Activate method on the Document object
I've tried Calling the Activate method on the Window object of the document
objects window collection

but neither of these sem to make Doc2 the active document and or bring Word
itself to be the top level app

Thanks in advanace

Andrew
 
A

Andrew Kennard

Ah ! think i've got it

Seem you need to get the Windows collection form the application object.
Activate the appropriate one of those and then call Activate of the
application object again

Now just trying to work out how to get it out of a minimized state without
locking ?

Cheers
 
A

Andrew Kennard

.... and that was my own feature !!!

Andrew Kennard said:
Ah ! think i've got it

Seem you need to get the Windows collection form the application object.
Activate the appropriate one of those and then call Activate of the
application object again

Now just trying to work out how to get it out of a minimized state without
locking ?

Cheers
 
J

Jean-Guy Marcil

Andrew Kennard was telling us:
Andrew Kennard nous racontait que :
Hi all

I am automating Word 2003

I've attached to and existing word instance got the documents
collection.
Looked through the document objects in it and found the one I want to
"activate" but I cant seem to get it to be the top level window

ie I have 3 word docs open Doc1, Doc2, Doc3. Doc1 is on top and Doc3
is on the bottom

After my search I've found that I want Doc2 to be the top/active
document
I've tried Calling the Activate method on the Document object
I've tried Calling the Activate method on the Window object of the
document objects window collection

but neither of these sem to make Doc2 the active document and or
bring Word itself to be the top level app

Where are you automating it from?
Can we see the relevant code?
Could there be other Word instance(s) running parallel to yours?

With Word 2003, the following works (I put the code in Normal.dot, created
three documents, added text to all three and left the focus on the first
one).

'_______________________________________
Sub test()

Dim docTarget As Document
Dim i As Long

For i = 1 To Documents.Count
If Right(Documents(i).Name, 1) = 2 Then
Set docTarget = Documents(i)
Exit For
End If
Next

docTarget.Activate

End Sub
'_______________________________________

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

Andrew Kennard

Jean-Guy

I am using a language called Visual Dataflex so a code sample would probably
not mean much here !

Thanks for your code

Andrew
 

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