The idea is to open two windows of same Excel workbook at the same time, side-by-side, with specific window dimensions. For demonstration purposes I prepared an example of new workbook "Book1.xlsm" with two Worksheets ("Sheet1" and "Sheet2"). After pressing the "CommandButton1", there should be two windows of the Workbook placed on my monitor side-by-side ("Sheet1" on the left and "Sheet2" on the right) with next properties:
- Left window showing "Sheet1" (Top=0, Left=0, Height=880, Width=960)
- Right window showing "Sheet2" (Top=0, Left=960, Height=880, Width=960)
I have two-monitor setup with screen resolution 1920×1200 each. You can see now that I'm trying to place each window on one half of one monitor (2 × 960 px = 1920 px).
BUT(!) when the code is executed, the size and position of both windows are all WRONG:
- Left window showing "Sheet1" (Top=-2, Left=-2, Height=1173, Width=1280)
- Right window showing "Sheet2" (Top=-2, Left=1278, Height=1173, Width=1280)
Does anyone know why is Excel ignoring size properties set in code and positions windows on these BIZARRE coordinates? Would you be so kind and test the code and posts the results here? Thank you in advance! Here is also the code behind "CommandButton1":
Disclamer: since I'm quite of noob in VBA, I'm gathering code parts from all over the internet. The code above is modified code, found on Stack overflow.
Bookmarks