views:

78

answers:

1

I know how to open an Internet explorer from within an VBA application. But how to I get "return" values from the running explorer to the VBA application. E.g let us assume I try to access http://page_not_there and got back an Error 400

How can I get this value in my VBA Application and act accordingly. Any hints or links or programming examples would be very welcome

Of fine editing is possible. So the order is: Information is send, and i get back an HTML string which can be used from within IE to sign a document. Of course for that one has to click a bit around in IE but at the end I get a sort of "feedback" if signing was successfull and I need this "feedback" to know if I can proceed.

I've close my windows boxes so take his with some caution. I start IE like this

set ie = CreateObject("InternetExplorer.Application")
ie.navigate2 "to_where_I_want"

That's all.

I then get a page where a Java applet is running for signing the URL choosen above ("to_where_I_want") I have few buttons there and after hitting on signing I have to type in my PIN and then I'M interested in the output of the IE Explorer.

As I understand you post I better create a form with a Web control and use this for browsing and Signing

Regards Friedrich

+1  A: 

Here are some notes on one way to get the status of a page.

   Dim http As Object
   Dim xmlhttp As Object

       Set http = CreateObject("MSXML2.ServerXMLHTTP.4.0")
       Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")

       On Error Resume Next

       xmlhttp.Open "GET", url, False
       ''This alternative can return status 405 in some cases
       ''xmlhttp.Open "HEAD", url, False
       xmlhttp.Send ""

       ''You can get the status of the page
       Status = xmlhttp.Status

       If Err.Number <> 0 Or Status <> 200 Then
           IsLink = False
       Else
           IsLink = True
       End If

       Set xmlhttp = Nothing

EDIT: Some Notes re Comments

Assuming that there is a form called WBForm with a control called WB, which is a Microsoft Web Browser control:

 ''Navigate to a non-existent page 
 Forms!WBForm!WB.Navigate "http://lessthandot.com/somepage.htm"
 ''Title of the page
 MsgBox Forms!WBForm!WB.Document.Title

The title will contain "HTTP 404 Not Found" in the case above. The document can also be read using the various elements.

The document object model Scripting with Elements and Collections

Remou
This isn't getting the HTTP status code from the embedded IE webbrowser control, this is creating an XML Http Request object and getting the status code from that. Completely different things.
jeffamaphone
While this is not exactly what was asked for, it works in VBA.
Remou
@Remou's answer is actually better, as you don't have to display the result in a browser control to work with it. The original question is flawed, in my opinion, as it privileges the browser control over working directly with the results.
David-W-Fenton
What's the flaw please? Ah I see I just mentioned the status code.It seems i can not edit my question. So here we go: The browser is called because of signing a document. So it's not enough just to "hit-and-run" one has to find out what's going on. The code above works if you just want to get a page and it's return value. So it does not answer my question and therefor I feeel free to downvote it.
Friedrich
Sorry, I can not modiy my comment above. I upvoted because this would be the way to go if I did not have to do any work with the page I'm loading. Unfortunatly it seems I can not edit my original question to clarify it. So it must be here in the comment. I need to sign a document in the Browser and need at the end some way to check whether this signing was successfull or not.
Friedrich
Is this http://www.aleksey.com/xmlsec/api/xmlsec-notes-sign.html the kind of signing you mean (I realize it is not the language you want)?
Remou
In principal. But the signing is done in the Explorer and I do not want to "change" that. The used tool is sec Web Signer IIRC. Howerver I like my user to get "used" to use the IE. And so the IE is normally started and this loads a Java applet for signing. And I want to see if this "signing" was successfull.
Friedrich
Okay, how do you feel about reading the html from the page?
Remou
"Okay, how do you feel about reading the html from the page"How do I do that from a running IE? That's the question.
Friedrich
I have added some notes. I can possibly give a better answer if you add a little code to your post.
Remou
Ok I conclude this is the best suggestion which has come up.
Friedrich