Change value on web id on a already opened application

Justice98

New Member
Joined
Jun 15, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I have the following codes, but instead of creating a new object(Internet Explorer) I want to change a value on the Internet Expolorer sheet that is already open. How can I do this or combine these macros.

VBA Code:
Sub Change_value_Internet_sheet()

    Dim IE As Object
    Dim doc As HTMLdocument
    Set IE = CreateObject("Internetexplorer.Application")
    
    
    IE.Visible = True
    IE.Navigate "https://www.mrexcel.com/search/"
    
    Do While IE.Busy
    Application.Wait DateAdd("s", 1, Now)
    Loop
    
    Set doc = IE.Document
    Windows("Test").Activate
    Range("A1").Select
    With doc
    .getElementById("field-email").Value = Range("A1").Value
    End With
    
End Sub

VBA Code:
Sub Active_Internet_sheet()
Dim sw As Object, IE As Object
    Set sw = CreateObject("Shell.Application").Windows
    
    For Each IE In sw
        'distinguish Internet Explorer from Windows Explorer
        If InStr(UCase(IE.FullName), "\IEXPLORE.EXE") <> 0 Then
            ShowWindow IE.hwnd, 2
            ShowWindow IE.hwnd, 3
            SetActiveWindow IE.hwnd
        End If
    Next
End sub

And I prefer using the Microsoft Edge as browser (for this macro), but I read that it is not possible, can someone confirm this?

Any help is much appreciated!

Kind regards,
Justin
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top