Excel VBA: Navigate Digital Certificate

When running the below code in Excel VBA, two Internet Explorer Certificate messages appear. They specifically appear when it gets to  the fifth line (i.e., ".send".) What VBA code do I add to the below code to make it physically navigate the two certificate messages I mentioned above? (i.e., 'Click Enter, Tab, Enter etc.,)

Keep in mind that this can be kind of tricky, because VBA pauses as soon as the certificates appear and continues only after the certificates are navigated. I was thinking maybe there is a way to force the certificates to appear without VBA pausing and somehow using API to navigate them. (Pictures of the Certificates are attached.)

Dim vGetHttp
Dim vUrlLink as string   '<-----https link designated by the user.
Set vGetHttp = CreateObject("MSXML2.XMLHTTP.6.0")
vGetHttp.open "Post", vUrlLink, False
vGetHttp.send  '<----------------Internet Explorer Certificates appear after this line initiates.
Msg-Cert1.JPG
Msg-Cert2.JPG
ouestqueAsked:
Who is Participating?
 
xtermieCommented:
For the first case/image it seems like you need to install your certificate for the current user
1.  Navigate to your target URL in Internet Explorer, ignore any cert warnings it gives you.
2.  Click the "lock" near the address bar (assuming IE7 or 8),
3.  Hit the "View Certificates", then go to the "Certification Path" tab.
4.  Double-click the topmost one- if no certificates, just go back to the "General" tab (you're already on the root cert in that case).
5.  Click "Install Certificate" and click through the import wizard.

If it still doesn't work, try installing Fiddler and watching the SSL negotiation- you can see why it might fail (invalid certificate dates, etc). You can tweak the generated VBA client sometimes to get past these issues, but again, it's best to just use a real and valid cert on the server if you're doing this for a production app

For the second case it seems to be different.
In both cases you can try sending keys to accept the windows' default (and accept in the 2nd case).  Read more here:
https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys(v=vs.110).aspx
and
http://www.contextures.com/excelvbasendkeys.html
0
 
ouestqueAuthor Commented:
Hey xtermie. I have a couple of questions about your answer.

Part 1: Before reviewing your answer, I already had a valid certificate installed. Are you saying I should re-install it? Currently data is pulled correctly. Nonetheless, each time VBA runs to pull the data, the certificate appears and the user has to navigate the certificate for the code to continue pulling data successfully. My goal is to make it so that the user does not have to accept a certificate each time the VBA runs.  Is it possible the vendor designed the certificate this way? Is it possible to accept a cert once and never have to accept it again?

Part 2: In my question, I mentioned that the VBA code pauses right at line 5 (i.e., vGetHttp.send) and waits for the user to navigate the certificates. Once this is done the VBA continues successfully. Problem is no more VBA runs, including SendKeys, until the user navigates the certificates. Are you saying there is a way to force SendKeys to run and navigate the certificates, even though VBA is paused? If so how?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.