• Address multiple monitors in VBA macro? (Word 2002

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Address multiple monitors in VBA macro? (Word 2002

    Author
    Topic
    #388162

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #680537

      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

      • #680542

        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.

        • #680652

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

          StuartR

          • #680678

            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,

    Viewing 0 reply threads
    Reply To: Address multiple monitors in VBA macro? (Word 2002

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: