Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Mar 2001
    Location
    Hampton, Virginia, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Address multiple monitors in VBA macro? (Word 2002

    I have written a macro that tiles Word documents on the screen (target document on one side and source document(s) on the other) and facilitates switching among the source documents for copying/pasting purposes. The objects I use are Application (.UsableHeight, .UsableWidth), ActiveWindow (.Document, .ActivePane, .Left, .Top, .Width, .Height), etc.

    In my dual-monitor environment the macro always puts all windows on the primary monitor irrespective of where the windows were to start with. Can anyone steer me to some object/property that would let me set an origin on the current monitor, whichever it happens to be?

    Many thanks.

    John.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Address multiple monitors in VBA macro? (Word 2002

    If you position a document on the second display and use VBE to interrogate its properties, can you determine whether there an offset to the coordinates, or some other property, that would help here? If I had two monitors, I'd do this by creating a program along these llnes (hastily typed in here and not tested):

    Sub CheckObjectProps()
    Dim winActive as Window
    Set winActive = ActiveWindow
    Stop ' open Locals window to inspect properties of winActive
    Set winActive = Nothing
    End Sub

  3. #3
    Lounger
    Join Date
    Mar 2001
    Location
    Hampton, Virginia, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Address multiple monitors in VBA macro? (Word

    I'm grateful for your suggestion. Of course I tried it immediately. Unfortunately, nothing jumped out at me saying "I'm the one". I looked at the Application, Active Window, and a few other objects. Whatever I'm looking for is probably easy to miss. Many thanks, anyway, for your response.

    John.

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Address multiple monitors in VBA macro? (Word

    Did you look at ActiveWindow.Top and .Left to see if these are cumulative?

    StuartR

  5. #5
    Lounger
    Join Date
    Mar 2001
    Location
    Hampton, Virginia, USA
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Address multiple monitors in VBA macro? (Word

    That's the answer! If the document starts out on my secondary screen (which is to the right of the primary), then ActiveWindow.Left is greater than Application.UsableHeight. I imagine if my secondary monitor were to the left then ActiveWindow.Left would be negative. It should be easy to fix now. Many thanks!

    Regards,

Posting Permissions

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