Connection to a secure site for which the username and password are to be given on a popup

  • Thread starter Thread starter Legacy 391147
  • Start date Start date
L

Legacy 391147

Guest
Hello everybody,

I am trying to write a macro that allows an Excel file to connect a secure website.

The problem is that the username and the password are not to be given directly on the website but on a popup that appears automatically.

Could somebody help me, please? I don't know how to operate on the popup.

The website is https://groupe-france.adecco.net

Thank you in advance.

Regards,
Yohann
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
The link I posted has the code you need. All you have to do is "View Source" on the webpage and change the code to look for the elements on your webpage. If you want someone to do this for you then try the Excel bounty section where you can pay people for their work.
 
Upvote 0
hello,

thank you for you reply, but it is not possible to read the source of the URL because the appearance of the popup prevents that.
I have found a solution (thank you Internet) in using a script and the SendKeys method.

It is based on the following solution: https://youtu.be/G-2khNFYQl8

I lanch a script contained in a VBS file at the beginning of the macro; it scrutinizes the appearance of the popup and sends then the login/password with Sendkeys.

VBS contents:
Code:
<code>[COLOR=#2600FF][B]Set[/B][/COLOR] oWSH = CreateObject([COLOR=#800000]"WScript.Shell"[/COLOR])

[COLOR=#2600FF][B]Do[/B][/COLOR]
     ret = oWSH.AppActivate ([COLOR=#800000]"Sécurité de Windows"[/COLOR]) 'name of the popup
[COLOR=#2600FF][B]Loop[/B][/COLOR] [COLOR=#2600FF][B]Until[/B][/COLOR] ret = [COLOR=#2600FF][B]True[/B][/COLOR]

WScript.Sleep 500
ret = oWSH.AppActivate ([COLOR=#800000]"Sécurité de Windows"[/COLOR])
 
[COLOR=#2600FF][B]If[/B][/COLOR] ret = [COLOR=#2600FF][B]True[/B][/COLOR] [COLOR=#2600FF][B]Then[/B][/COLOR]
     ret = oWSH.AppActivate ([COLOR=#800000]"Sécurité de Windows"[/COLOR])
     WScript.Sleep 10
     
     '[COLOR=#008000]Passing the value UserName/UserID
[/COLOR]     oWSH.SendKeys [COLOR=#800000]"XXXXXXXXXXXXXXXXX"[/COLOR]
     WScript.Sleep 10
     
     [COLOR=#008000]'Changing the focus to password textbox
[/COLOR]     oWSH.SendKeys [COLOR=#800000]"{TAB}"[/COLOR]
     WScript.Sleep 10
     
     [COLOR=#008000]'Passing the value password
[/COLOR]     oWSH.SendKeys [COLOR=#800000]"XXXXXXXXXXXXXXXXX"[/COLOR] [COLOR=#008000]'password
[/COLOR]     WScript.Sleep 10
     
[COLOR=#008000]     'Clicking enter to complete the screen
[/COLOR]    oWSH.SendKeys [COLOR=#800000]"{ENTER}"[/COLOR]
[COLOR=#2600FF][B]End[/B][/COLOR] [COLOR=#2600FF][B]If[/B][/COLOR]

[COLOR=#008000]'Releasing the script object
[/COLOR][COLOR=#2600FF][B]Set[/B][/COLOR] oWSH = [COLOR=#2600FF][B]Nothing[/B][/COLOR]
WScript.Sleep 500</code>

And in the macro, we have:
Code:
<code>Shell [COLOR=#800000]"wscript.exe "[/COLOR][COLOR=#800000]"path\file.vbs"[/COLOR][COLOR=#800000]""[/COLOR]</code>

My problem is that the script is still running after the end of the macro.

Does somebody have an idea to stop the script, please?

Thank you.
Yohann
 
Upvote 0
This could create an endless loop. If the window is never recognized then the program will be stuck here forever. I recommend making a timeout. Network timeouts are often 30 seconds. Have it pop an error like "Timeout waiting for Sécurité de Windows" that way you know the code got stuck in the loop.

Code:
<code>[COLOR=#2600FF][B]Do[/B][/COLOR]      ret = oWSH.AppActivate ([COLOR=#800000]"Sécurité de Windows"[/COLOR]) 'name of the popup [COLOR=#2600FF][B]Loop[/B][/COLOR] [COLOR=#2600FF][B]Until[/B][/COLOR] ret = [COLOR=#2600FF][B]True[/B][/COLOR]</code>
 
Upvote 0
Thank you... but, even if the window is recognized, I have the problem.
For example, if the macro does the job (the window appears, the script enters login/password, etc. until the End Sub), all seems to be OK, but if I go on the related website manually, since the popup appears... the script enters the login/password. :( And I must pass by Tasks manager to stop it.

Thank you for your help.
 
Upvote 0
Looks like you need a quit like this:

Code:
Wscript.Quit

You can also give the whole script a timeout and it will close wscript if it runs longer than a given time:

Code:
<code>Shell [COLOR=#800000]"wscript.exe "[/COLOR][COLOR=#800000]"path\file.vbs"[/COLOR][COLOR=#800000]" //T:60"[/COLOR]</code>

That "T:60" says that it will quit wscript if it runs longer than a minute.
 
Upvote 0
Without using
Code:
Wscript.Quit

But just with
Code:
<code>Shell [COLOR=#800000]"wscript.exe "[/COLOR][COLOR=#800000]"path\file.vbs"[/COLOR][COLOR=#800000]" //T:20"[/COLOR]</code>

It does work.

Thank you very much for your help ! :)

Yohann

https://peacewithgod.net/
 
Upvote 0

Forum statistics

Threads
1,223,789
Messages
6,174,576
Members
452,573
Latest member
Cpiet

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