Close web page in VBA EXCEL from a UserForm

Solved
LANXADE Alain Posted messages 34 Status Member -  
LANXADE Alain Posted messages 34 Status Member -
Good evening,
Windows 7 - Excel 2007 -

Via a UserForm and a CommandButton, I open a WEB page: "Https://www.S ......." . I would like to close this web page with the "Escape" key

The code starts like this:
Private Sub CommandButton2_Click()
ActiveWorkbook.FollowHyperlink Address:="Https://www.S .......fr.htm"
End Sub

The Escape key command would be included in the code above.
for example:
Private Sub CommandButton2_Click()
ActiveWorkbook.FollowHyperlink Address:="Https://www.S .......fr.htm"
<code>If ECS = press then page web close
End If
End Sub

Thanks in advance for your help.

2 answers

gbinforme Posted messages 14930 Registration date   Status Contributor Last intervention   4 744
 
Hello,

It seems to me that this will be a bit more complicated than you imagine.
Indeed, your first command launches your default browser which will display your page in a tab.
To close that tab, you would therefore need to use Windows APIs that can act on the process, provided you know how to identify the process in question and use the appropriate method for the browser in question.
If you open and close your page in quick succession, what’s the point?
If you want to retrieve information, it seems to me that web requests would be better suited since they are managed by Excel.
--
Always zen
Perfection is not achieved when there is nothing more to add, but when there is nothing left to remove. Antoine de Saint-Exupéry
0
LANXADE Alain Posted messages 34 Status Member
 
Good evening gbinforme,

Thank you for your reply.
I will get started on the web requests managed by Excel.

Good night and thank you again
0