Modifying a VBA to set size & position of window of another workbook

  • Hi!


    Below macro when run, opens a new excel window of the same workbook (lets say Book1.xlsm) and is used to set the size and position of both the worksheet windows on the screen.


    However, besides setting the size and position of both the windows of the current workbook, I also need to set the size and position of another workbook (lets say Book2.xlsx) with the same macro. Book2.xlsx will be open at the time of running the macro.



    Can someone please modify this code so as to do this?



    PS:
    1. I know that my requirement can be met by using the Save layout option of Excel, but there are a few reasons why that is working for me.
    2. Also, Book2's size and position can also be set by running a similar macro from within that, but I cannot change the file format of the other file from .xlsx to .xlsm.


    Sample file attached

    Thanx,


    Naira

  • Re: Modifying a VBA to set size & position of window of another workbook


    Example syntax

    Best Regards,
    Luke M
    =======
    "A little knowledge is a dangerous thing."

  • Re: Modifying a VBA to set size & position of window of another workbook


    Those looking to use the above code may find the following codes useful as well:


    This one is used to activate another window (apart from the window from where the VBA code was initially run:

    Code
    Windows(2).Activate

    where the no. in the bracket is the window no. one would see in the workbook caption.


    This code would be useful if one wants to activate (bring in front) another workbook, other than the workbook from where the code was initially run:

    Code
    Application.Windows("book2.xlsx").Activate

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!