"Activating" a new IE window

Crewchief521

New Member
Joined
Apr 14, 2019
Messages
18
I have some code that runs flawlessly on my computer, but when i try it on a co-workers computer, the new IE window opens up in the background and the sendkeys lines of code dont work. Any ideas on why it works on mine but not theirs? I have searched and tried just about anything i could think of. Here is the code
Code:
Sub getAWPdata()    Dim IE As SHDocVw.InternetExplorer
    Dim HTMLDoc As MSHTML.HTMLDocument
    Dim HTMLInput As MSHTML.IHTMLElement
    Dim HTMLAs As MSHTML.IHTMLElementCollection
    Dim HTMLA As MSHTML.IHTMLElement
    Dim wb As Workbook
    Dim oShell As Object
    
    Set oShell = CreateObject("WScript.Shell")
 
    Application.ScreenUpdating = False
    
    If MsgBox("Please make sure you have an active MRO Apps session open!", vbOKCancel, "Active Session") = vbCancel Then Exit Sub
    
    MsgBox "This process will take about 2 minutes to complete, please be patient.", vbOKOnly, "Process Time"
    
    Set IE = New InternetExplorerMedium
    
    'open IE to MRO Apps


    IE.Visible = True
    
    IE.Navigate "https://mro.hill.af.mil/MROApps/spring/awpData"
    
    Do While IE.ReadyState <> READYSTATE_COMPLETE
        Loop
        
    oShell.AppActivate IE.Name
    
    Set HTMLDoc = IE.Document
    
    Application.Wait (Now + TimeValue("00:00:10"))
    
    'click export to csv link
    Set HTMLInput = HTMLDoc.getElementById("form:btnCsvExport")
        HTMLInput.Click
    
    Application.Wait (Now + TimeValue("00:00:10"))
    
    'open new excel file
    SendKeys "%{N}"
    
    Application.Wait (Now + TimeValue("00:00:01"))


    SendKeys "{ENTER}"
    
    'run procedure "CopyAWPData
    
    Application.OnTime Now + TimeValue("00:00:20"), "CopyAWPData"
    
    'run procedure "getSOSdata
    Application.OnTime Now + TimeValue("00:00:20"), "getSOSdata"
    
    SendKeys "{NUMLOCK}", True
    Application.ScreenUpdating = True
    IE.Quit


End Sub
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,816
Messages
6,181,143
Members
453,021
Latest member
Justyna P

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