AppActivate After opening Web Brower

gmooney

Active Member
Joined
Oct 21, 2004
Messages
254
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the following code that essentially looks for a downloaded file before launching the URL and automatically downloading a file.

I want the Excel file to return to focus but this code is not and it is staying on the web browser, thus I have to click on Excel from the taskbar. Any ideas how to get Excel back to be displayed?

VBA Code:
Sub GetURL()

    Dim NewURL As String
    Dim FollowURL As String

    NewURL = ThisWorkbook.Sheets("Category Review").Range("AP107").Value
    
    CheckforDuplicateDownloadFile
    
    ThisWorkbook.FollowHyperlink NewURL
    
    'Sheets("Instructions").Select
    
    AppActivate "Category Review Builder"
    
    WaitForFileDownload
    
    
    
    BuildMyCategoryReview
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Just pick a place to upload your file to and then provide the the link to the file here. For example here <---
 
Upvote 0
Yes. You should be running GetURL .. lol
OK. Down to the final piece....below is my GetURL and yours. What do I need to take from yours into mine in order to get the Excel to reappear: Remembering that it could be CHrome or Edge browsers?

VBA Code:
Sub GetURL()

    Dim NewURL As String
    Dim FollowURL As String

    NewURL = ThisWorkbook.Sheets("Category Review").Range("AP107").Value

    CheckforDuplicateDownloadFile

    ThisWorkbook.FollowHyperlink NewURL

    'Sheets("Instructions").Select

    AppActivate "Category Review Builder"

    WaitForFileDownload

    BuildMyCategoryReview

End Sub

'Sub GetURL()
'
'    Dim NewURL As String
'    Dim FollowURL As String
'
'    NewURL = ThisWorkbook.Sheets("Category Review").Range("AP107").Value
'
'    CheckforDuplicateDownloadFile
'
'    With CreateObject("InternetExplorer.Application")
'        .Visible = True
'        .navigate NewURL
'        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
'        End With
'
'        Call BringWindowToFront(Application.hwnd)
'
'        WaitForFileDownload
'
'        BuildMyCategoryReview
'
'End Sub
 
Upvote 0
Summarization:

gmooney remaining code
VBA Code:
    CheckforDuplicateDownloadFile

    ThisWorkbook.FollowHyperlink NewURL

    'Sheets("Instructions").Select

    AppActivate "Category Review Builder"

    WaitForFileDownload



Jaafar Tribak code
VBA Code:
    CheckforDuplicateDownloadFile
'
    With CreateObject("InternetExplorer.Application")
        .Visible = True
        .navigate NewURL
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
    End With
'
    Call BringWindowToFront(Application.hwnd)
'
    WaitForFileDownload
 
Last edited:
Upvote 0
OK. Down to the final piece....below is my GetURL and yours. What do I need to take from yours into mine in order to get the Excel to reappear: Remembering that it could be CHrome or Edge browsers?

Take the second GetURL (ie: my GetURL).
But, this will only work with IExplorer .
I am not familiar with the object model of Chrome or Edge browsers (assuming these browsers expose some Properties like Busy and ReadyState to wait until the page is fully loaded)

Otherwise, you will need to add a pause after launching the url and before calling the BringWindowToFront routine.
 
Upvote 0
Take the second GetURL .
But, this will only work with IExplorer .
I am not familiar with the object model of Chrome or Edge browsers (assuming these browsers expose some Properties like Busy and ReadyState to wait until the page is fully loaded)

Otherwise, you will need to add a pause after launching the url and before calling the BringWindowToFront routine.
Oh wow......sorry @Jaafar Tribak sorry that I didn't make it clear that I was lookfing for Chrome or Edge options here. @johnnyL any ideas?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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