Re: Using ActiveDocument when mutliple documents open




Thousands of people rely on ActiveDocument every day; if there is a problem it needs identifying. You are the only person, to my knowledge, seeing such a problem at the moment - perhaps it's SP2 or some other recent update causing it.

You seem to be coming across this often enough for it to be a problem so could you please tell us under precisely what conditions you see the problem and what actions (both inside and outside Word) precede its occurrence. Please include, at a minimum, the version of Word 2007 and updates applied, the operating system and version, other applications (at least all VBA-enabled ones) running at the time, the state of the "Windows in Taskbar" option, and any other options you think relevant.

--
Enjoy,
Tony

www.WordArticles.com

"Webboex" <Webboex@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:3D86C14E-2504-4E26-AAD0-5E73221AB721@xxxxxxxxxxxxxxxx
Even the simple macro:

Sub TestActiveDocument()
MsgBox ActiveDocument.Name
End Sub

cannot reliably identify the active document every time. I can only think it
has something to do with how Word 2007 handles its document windows. I have
never had a problem with it in earlier versions of Word.



"Tony Jollans" wrote:

I would expect Active Document to be as you say, and have never heard of
problems with it, but, and I am guessing a little, if you have "Windows in
Taskbar" set, there may be actions (Show Desktop, perhaps) that effectively
re-arrange the Windows so that what you thought was active is no longer
deemed so by the system.

--
Enjoy,
Tony

www.WordArticles.com

"Webboex" <Webboex@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E663B711-B466-419E-9D1D-800FBE4833B2@xxxxxxxxxxxxxxxx
> In Word 2007, if there are multiple documents open, ActiveDocument does
> not
> always refer to the last document I viewed or typed in and instead
> sometimes
> reverts back to the last document on which I used the procedure.
>
> As I can replicate this problem with a one line macro
> MsgBox ActiveDocument.Name
> the problem is not related to the complexity of the code I am trying to
> run.
>
> Is there any other way of referring to the document I last worked on or
> viewed?



.



Relevant Pages

  • Re: Using ActiveDocument when mutliple documents open
    ... Windows in Taskbar determines whether each document is shown as a separate window in the taskbar as well as Ctrl+F6, or whether document windows all exist within one parent Word Window. ... the problem with a one line macro I'm not sure it is relevant. ... > In Word 2007, if there are multiple documents open, ActiveDocument does ...
    (microsoft.public.word.vba.general)
  • Re: run some code before doc opening
    ... you would have to adapt ... If you check the name of the activedocument, ... Word 2002, Windows 2000 ... Prev by Date: ...
    (microsoft.public.word.vba.general)
  • Re: Changing the ActiveDocument mid stream
    ... if working with the activedocument goes wrong ... creating a new object and assigning the ... activedocument to it, (useless anyway) ... Word 2002, Windows 2000 ...
    (microsoft.public.word.vba.general)
  • RE: Word User Form "grabbing" active instance of Word
    ... template, then ThisDocument is the module your code should be in. ... Activedocument because if as part of an error situation the new document ... subroutine since all it does is exit the sub. ... AnForm can't be set to nothing ...
    (microsoft.public.word.vba.general)
  • Re: Duplicate data on First document and No data on the Second doc
    ... Sub openMedHistory(ByRef PFName As String, ByRef PLName As String) ... Do not use ActiveDocument, ...
    (microsoft.public.word.vba.general)