PDA

View Full Version : Solved: Vba to Okay Digital Cert and Signing data?



Celelond
01-24-2011, 03:23 AM
Hi all,

I have a web page I need to access every hour, on the hour.
I can bring up a web page no issue, and prefer to leave visibility as false, but on the one I have been asked to access I have a small issue.

When I navigate to the url, it then asks to choose a digital cerificate (I have only one that I can choose).
Once I okay this manually it then pops up another box, "Signing data with your private exchange key."

Both of these use an "OK" button, does anyone know a way I can write this into my code to ok both of these and move on the url?

I would deff prefer to have it not visible and not use sendkeys and mouse clicks.

Oh, another thing, once ont he page I run a report, this then bring us the File Download box, then the Save as box, any clues as how to let the code handle them? The Save as name for the folder would be Now as in the date and time at that moment.

Thanks for your help.

Celelond
01-24-2011, 04:38 AM
Got it, used Findwindow in the end.
If anyone has any other idea's be glad to hear them.

JP2112
01-24-2011, 12:59 PM
Does the site have an API you can use instead?

Can you post the URL so others can see it?

Shred Dude
01-25-2011, 11:16 PM
If you're automating IE to do this, another way might be to use the newwindow event on the browser to alert you to the presence of the pop up windows.

Then, with a reference to that pop up window, you could programatically advance past the OK button.

You'd need to set up code similar to this in a Sheet module, or in a separate Class module to utilize the withevents declaration

'Reference to Microsoft Internet Controls
'Reference to Microsoft HTML Object Library

'PLACE THIS CODE IN A SHEET MODULE

Private WithEvents ie As InternetExplorer
Private WithEvents iePopup As InternetExplorer
Private Sub ie_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set iePopup = New InternetExplorer
Set ppDisp = iePopup
End Sub

Public Sub getFile()
Dim URL As String

URL = "mywebiste.com"
Set ie = New InternetExplorer 'CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate URL
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop

'Do what ever you do on the primary page that triggers the pop up...

'Then wait for it...


Do Until .ReadyState = READYSTATE_COMPLETE _
And Not .Busy _
And (Not iePopup Is Nothing)
DoEvents
Loop

While iePopup.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend

'You now have reference to the pop up window...

With iePopup

'try to "Click" the "OK" in the PopUp window...

.document.getelementbyid("OKbutton").Click

'see where that gets you...

End With


End With 'ie

ie.Quit
Set ie = Nothing

End Sub