(Solved) – VBA – Send Keys IE11 Save/Open

(solved)-–-vba-–-send-keys-ie11-save/open

I have taken code off the boards to send-Keys to the IE11 Save/Open box that pop-ups when you export a file but it is not working (it is sending to the main browser). I cannot activate the Save/Open box & send the S button even when trying manually (using ALT S)

Do you require some settings to be able to send keys to this pop-up?

I have put a condensed version of the code below

Thanks

Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal HWND As LongPtr) As LongPtr

Sub OpenIE()

Dim objIE As InternetExplorer
Set objIE = New InternetExplorer

Dim HWNDSrc As LongPtr
HWNDSrc = objIE.HWND
SetForegroundWindow HWNDSrc


'From https://stackoverflow.com/questions/56893185/controlling-ie11-do-you-want-to-open-save-vba
 Do While objIE.Busy
                Application.Wait DateAdd("s", 1, Now)
            Loop

        'send Alt-S to save
            Application.SendKeys "%{S}"

 'Make sure IE is not busy
             Do While objIE.Busy
                 Application.Wait DateAdd("s", 1, Now)
             Loop

Leave a Reply

Your email address will not be published. Required fields are marked *