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:
Public Sub ChromeNewWindows()
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window -url https://www.facebook.com")
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url https://www.facebook.com")
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --new-window -url https://www.google.com")
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
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:
Dim FullWidth As Integer, FullHeight As Integer
With Application
.WindowState = xlMaximized
FullWidth = .Width
FullHeight = .Height
.WindowState = xlNormal
.Top = FullHeight - 100
.Left = FullWidth - 100
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.