Resize Chrome Windows using VBA / Shell Command

  • Hi!


    This is a follow-up thread from the thread to Open Chrome from VBA posted at Google Chrome VBA


    I am using following code to open 2 urls in 2 tabs in first chrome window and 1 url in another chrome window:

    Code
    1. Public Sub ChromeNewWindows()
    2. Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window -url https://www.facebook.com")
    3. Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url https://www.facebook.com")
    4. Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window -url https://www.google.com")
    5. End Sub

    The Chrome windows open nicely in maximized mode.


    However, I need to open both windows in specific window sizes and at specific locations on the screen, say:

    .Top = 100, .Left = 100 .Height = 100 .Width = 100 for window 1

    .Top = 100, .Left = 300 .Height = 150 .Width = 150 for window 2


    I have tried below code to resize and re-position the windows but it doesn't work. It seems that I probably need to open/ change Chrome window state to Normal state and then below code might work

    Code
    1. Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window -url http://www.google.com/ --chrome-frame --window-size=300,200 --window-position=80,40")


    Alternately, I use the below code to first maximize my excel window, get the screen size of the current monitor, change the excel application window state to Normal, and then resize and reposition my excel window based on my screen size. But I am unable to use the With Application command for the chrome window:


    Code
    1. Dim FullWidth As Integer, FullHeight As Integer
    2. With Application
    3. .WindowState = xlMaximized
    4. FullWidth = .Width
    5. FullHeight = .Height
    6. .WindowState = xlNormal
    7. .Top = FullHeight - 100
    8. .Left = FullWidth - 100
    9. End With

    Would appreciate if someone could recommend a working solution since my Shell skills are quite rusty.


    Note: Sample excel file attached for testing.


    Thanks.