Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Guys,
I use this code to split the IE browser and excel file windows side by side. Is it possible to change the IE frame to Chrome instead !
I use this code to split the IE browser and excel file windows side by side. Is it possible to change the IE frame to Chrome instead !
VBA Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare PtrSafe Function GetDesktopWindow Lib "user32" () As Long
Private Declare PtrSafe Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Declare PtrSafe Function MoveWindow Lib "user32" ( _
ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare PtrSafe Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Sub SideBySide()
Dim hwnd As Long
Dim R As RECT, LW As RECT, RW As RECT
'Get the size of the deskop
If GetWindowRect(GetDesktopWindow, R) = 0 Then Exit Sub
'Calculate the left and right side
LW = R
LW.Right = R.Left + (R.Right - R.Left) / 2
RW = R
RW.Left = R.Right - (R.Right - R.Left) / 2
'Move Excel to the Right
hwnd = FindWindow("XLMAIN", vbEmpty)
With RW
MoveWindow hwnd, .Left, .Top, .Right - .Left, .Bottom - .Top, True
End With
BringWindowToTop hwnd
'Move IE to the Left
hwnd = FindWindow("IEFrame", vbEmpty)
With LW
MoveWindow hwnd, .Left, .Top, .Right - .Left, .Bottom - .Top, True
End With
BringWindowToTop hwnd
End Sub