> I am in the process of migrating from Word 2002 to Word 2007 and have
> several macros developed in the later.
[quoted text clipped - 8 lines]
> I have tried various workarounds to sort this (SendKeys etc) to no
> avail. Any ideas would be welcome.
The most recently opened document should become the ActiveDocument, and I'm
not sure what would interfere with that. Unfortunately I'm away from my copy
of Word 2007 right now, so I can't test it to see if it behaves the same as
yours.
In any case, you can force it this way:
Dim wdDoc As Document
Set wdDoc = Documents.Open(strFileName)
wdDoc.Activate
If the document is already active, calling Activate on it won't do anything.
Technically, you can do this in one statement,
Documents.Open(strFileName).Activate
but it's usually a good idea -- especially when there are two or more
documents open at the same time -- to use an assigned Document object like
wdDoc to do all operations in the macro instead of using the ActiveDocument
object. Then you always know which document is going to be the target of the
operation. In fact, the document doesn't even have to be active to do things
like formatting, data extraction, Find/Replace, etc.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Tony Jollans - 28 Sep 2007 17:58 GMT
I'll second Jay on that. Do you have any AddIns (or code in the document or
its template) that might be doing something to change the ActiveDocument?
What do you see as you step through the code?

Signature
Enjoy,
Tony
>> I am in the process of migrating from Word 2002 to Word 2007 and have
>> several macros developed in the later.
[quoted text clipped - 33 lines]
> the target of the operation. In fact, the document doesn't even have to be
> active to do things like formatting, data extraction, Find/Replace, etc.
JRob - 29 Sep 2007 12:36 GMT
Thank you both for your replies. I will not be back in the office
until Monday so will try your suggestions then.
JRob - 01 Oct 2007 10:32 GMT
The file selection to open was displayed in a dialog box.
Interestingly
doc.Activate
Unload Me (unloading the dialog box)
does not make doc the active document
However:
Unload Me
doc.Activate
works perfectly
Russ - 02 Oct 2007 07:11 GMT
JRob,
> The file selection to open was displayed in a dialog box.
> Interestingly
>
> doc.Activate
> Unload Me (unloading the dialog box)
> does not make doc the active document
The above probably did not work because you opened the dialog in the default
modal (versus modeless) way, which meant that nothing could be selected
(activated) while the form (dialog) was still being shown.
> However:
> Unload Me
> doc.Activate
> works perfectly

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID