Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Returning index or name of next window (VBA Word 2000)

    Scenario:
    I have more than one document open.
    I minimize the activedocument.
    How to a return the name, fullpath, or index of the window I see next?

    The windows collection seems to be in alphabetical order, not the order the item appears when the active item is minimized.

    Thanks for the help!!
    Troy

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Returning index or name of next window (VBA Word 2000)

    What about
    ActiveWindow.Index
    or
    ActiveWindow.Document.Name
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Returning index or name of next window (VBA Word 2000)

    I've tried that, but the problem is that the minimized document remains the "ActiveWindow". This is the code I'm using:

    If Windows.Count > 1 Then
    Windows("Install.doc").WindowState = wdWindowStateMinimize
    T = ActiveWindow.Index
    End If

    Install.doc is initially the ActiveWindow. When I minimize it, it is still the active window unless I select the next visible window on top with the mouse or ALT+TAB to it.

    I've also tried the "Previous" property, but that is still going in alphabetical order, not in the order that the documents are displayed when one is minimized. I'm really trying to get to the last document open prior to opening the "Install.doc" file.

    Thanks for any help you can give!!
    Troy

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Returning index or name of next window (VBA Word 2000)

    You may want to explore the API window functions like FindWindow, GetWindowText and GetActiveWindow.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Returning index or name of next window (VBA Word 2000)

    I thought it might be an API thing.

    However, I've dipped my little toe in the API waters after your post, and found the water is much too cold for me to wade in. Can you or someone give me a function/procedure using one or more of these API calls to find the name of the window active after I minimize the currently active window (or forget minimizing and get me the next window that would be active). It seems like there ought to be something like a "Zorder" or something with regard to document windows within Word (or just windows within the operating system).

    Thanks again!!
    Troy

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Returning index or name of next window (VBA Word 2000)

    There are lots of great API sites. I like to refer people to http://www.allapi.net.
    Download the API Guide.

    But that's not necessarily the best tool for learning.

    Do a google on "API VB Window" or some reasonable facsimile thereof.

    As for a simple example, this sub gets the active window and flashes its titlebar

    Sub FlashActiveWindow()
    Dim hWnd As Long
    Dim rc As Long
    'hWnd = GetDesktopWindow
    hWnd = GetActiveWindow
    rc = FlashWindow(hWnd, 1)
    End Sub
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •