Scotchydog
New Member
- Joined
- Apr 27, 2022
- Messages
- 2
- Office Version
- 365
- 2016
- Platform
- Windows
I am using Office 365 and am attempting to control a Terminal Style Internet Explorer Tab (Flynet Terminal Emulator).
I have the following code (below) which works perfectly so far to create an instance of IE, automatically log on and navigate to the correct menu.
What I would like to be able to do is to switch focus between Excel and IE via VBA Macros so I can fully control the terminal screen according to the user's needs.
I am sure there are better ways to do this via Chrome / Selenium etc. however I would prefer to stay within IE.
Just need to know how to switch focus and visibility back and forth between Excel and IE.
Cheers for any help.
Private Sub ControlFlynet()
Dim oIE As Object
Dim oHDoc As HTMLDocument
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
Set oIE = CreateObject("InternetExplorer.Application")
sSiteName = "https://flynet.dealer-services.com.au/nissan/"
' Open Internet Explorer Browser and keep it visible.
With oIE
.Visible = True
.Navigate sSiteName
End With
While oIE.ReadyState <> 4
DoEvents
Wend
Set oHDoc = oIE.Document
Application.Wait Now + TimeValue("00:00:10")
SendKeys ("S103150")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{TAB}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("Ftg1000")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("V{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("V{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("C{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("^a")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("^c")
Application.Wait Now + TimeValue("00:00:01")
DataObj.GetFromClipboard
strpaste = DataObj.GetText(1)
oIE.Quit
SendKeys ("{ENTER}")
End Sub
I have the following code (below) which works perfectly so far to create an instance of IE, automatically log on and navigate to the correct menu.
What I would like to be able to do is to switch focus between Excel and IE via VBA Macros so I can fully control the terminal screen according to the user's needs.
I am sure there are better ways to do this via Chrome / Selenium etc. however I would prefer to stay within IE.
Just need to know how to switch focus and visibility back and forth between Excel and IE.
Cheers for any help.
Private Sub ControlFlynet()
Dim oIE As Object
Dim oHDoc As HTMLDocument
Dim DataObj As MSForms.DataObject
Set DataObj = New MSForms.DataObject
Set oIE = CreateObject("InternetExplorer.Application")
sSiteName = "https://flynet.dealer-services.com.au/nissan/"
' Open Internet Explorer Browser and keep it visible.
With oIE
.Visible = True
.Navigate sSiteName
End With
While oIE.ReadyState <> 4
DoEvents
Wend
Set oHDoc = oIE.Document
Application.Wait Now + TimeValue("00:00:10")
SendKeys ("S103150")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{TAB}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("Ftg1000")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("V{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("V{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("C{ENTER}")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("^a")
Application.Wait Now + TimeValue("00:00:01")
SendKeys ("^c")
Application.Wait Now + TimeValue("00:00:01")
DataObj.GetFromClipboard
strpaste = DataObj.GetText(1)
oIE.Quit
SendKeys ("{ENTER}")
End Sub