AppActivate to return to excel

I am writing code to download a file from a website, but I have to use Chrome for it. I used the shell command to open Google Chrome at the desired URL, and right after the shell command I tried to use the AppActivate command, but it does not work.

The command is as follows:

Sub DL(URL as string)

    Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url URL")
    AppActivate ("MicroSoft Excel - SIEVE")

End Sub

SIEVE is the name of my book. I tried to use only MicroSoft Excel, Excel and other combinations, but only with MicroSoft Excel and Microsoft Excel - SIEVE I did not receive an error message.

Can anybody help me?

+3
source share
2 answers

I do not think you need to indicate the name of your book.

Try the following:

Sub DL(URL As String)

Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url URL")
AppActivate "MicroSoft Excel"

End Sub

, , AppActivate:

Workbooks("SIEVE").Activate

Edit

AppActivate, , , . , Chrome , Chrome AppActivate. , , Application.Wait() Chrome. - :

Sub DL(URL As String)
    Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url URL")

    Application.Wait (Now + TimeValue("0:00:10")) '<~~ Waits ten seconds.

    AppActivate "MicroSoft Excel"
End Sub
+2

:

On Error Resume Next
**AppActivate Application.Caption**
On Error GoTo 0
-1

All Articles