Hi All,

I am attempting to automate a job which requires navigating through a
website with internet explorer. I don't wish to use the
InternetExplorer.Application object as I have found flaws with it. I am
using SendKeys and WScript and the MICROSOFT.XMLHTTP object to obtain the
contents of the pages as I go. In a former script I was able to obtain
textbox & button objects on a page with the InternetExplorer.Application
object.

eg.
set itms = ie.Document.All
itms.username.value = user

How can I acheive the same result with other objects? I have the
MICROSOFT.XMLHTTP object for the page.

Thanks,
Jesse

Re: HTML DOM by Joe

Joe
Wed Nov 03 03:03:42 CST 2004

"Jessard" <Jessard@discussions.microsoft.com> wrote in message
news:DA78D9D0-EC72-4634-8DCC-0C110C041D5D@microsoft.com...
> Hi All,
>
> I am attempting to automate a job which requires navigating through a
> website with internet explorer. I don't wish to use the
> InternetExplorer.Application object as I have found flaws with it. I am
> using SendKeys and WScript and the MICROSOFT.XMLHTTP object to obtain the
> contents of the pages as I go. In a former script I was able to obtain
> textbox & button objects on a page with the InternetExplorer.Application
> object.
>
> eg.
> set itms = ie.Document.All
> itms.username.value = user
>
> How can I acheive the same result with other objects? I have the
> MICROSOFT.XMLHTTP object for the page.
>
> Thanks,
> Jesse
You can't do it with MICROSOFT.XMLHTTP (which is an obsolete classname, use
msxml2.XmlHttp.4.0 or 3.0), although you can retrieve the text of the page
it still needs parsing by an HTML parser.
Are you trying to just read information from the page or do you need to
click on buttons etc?
What flaws did you find with IE?
--

Joe (MVP - xml)



Re: HTML DOM by Jessard

Jessard
Wed Nov 03 20:07:05 CST 2004

Hi, thanks for the reply.

Can you explain differences between MICROSOFT.XMLHTTP and
msxml2.XmlHttp.4.0. Does msxml2.XmlHttp.4.0 parse also? What happens when I
navigate to a URL which is for a file and not a HTML page?

I am trying to somehow assign values to textboxes and click a button. But
the end result requires downloading files (that are not HTML documents).

When i use the IeApp object there are issues when there is already another
browser window open. If a browser window is open and i run a vbscript to do
my task it simply flashes down in the taskbar and sendkeys fail etc.

Jesse

"Joe Fawcett" wrote:

> "Jessard" <Jessard@discussions.microsoft.com> wrote in message
> news:DA78D9D0-EC72-4634-8DCC-0C110C041D5D@microsoft.com...
> > Hi All,
> >
> > I am attempting to automate a job which requires navigating through a
> > website with internet explorer. I don't wish to use the
> > InternetExplorer.Application object as I have found flaws with it. I am
> > using SendKeys and WScript and the MICROSOFT.XMLHTTP object to obtain the
> > contents of the pages as I go. In a former script I was able to obtain
> > textbox & button objects on a page with the InternetExplorer.Application
> > object.
> >
> > eg.
> > set itms = ie.Document.All
> > itms.username.value = user
> >
> > How can I acheive the same result with other objects? I have the
> > MICROSOFT.XMLHTTP object for the page.
> >
> > Thanks,
> > Jesse
> You can't do it with MICROSOFT.XMLHTTP (which is an obsolete classname, use
> msxml2.XmlHttp.4.0 or 3.0), although you can retrieve the text of the page
> it still needs parsing by an HTML parser.
> Are you trying to just read information from the page or do you need to
> click on buttons etc?
> What flaws did you find with IE?
> --
>
> Joe (MVP - xml)
>
>
>

Re: HTML DOM by Joe

Joe
Fri Nov 05 06:10:19 CST 2004

"Jessard" <Jessard@discussions.microsoft.com> wrote in message
news:43FB7156-1C3D-460C-B45A-EF87686CD429@microsoft.com...
> Hi, thanks for the reply.
>
> Can you explain differences between MICROSOFT.XMLHTTP and
> msxml2.XmlHttp.4.0.

MICROSOFT.XMLHTTP is an earlier less reliable version, depending on your
machine version you could get anything from version 2.6 to version 3.
msxml2.XmlHttp.4.0 is the latest general release.

>Does msxml2.XmlHttp.4.0 parse also? What happens when I
> navigate to a URL which is for a file and not a HTML page?
>
No, it can fetch "any" http resource.

> I am trying to somehow assign values to textboxes and click a button. But
> the end result requires downloading files (that are not HTML documents).
>
> When i use the IeApp object there are issues when there is already another
> browser window open. If a browser window is open and i run a vbscript to
do
> my task it simply flashes down in the taskbar and sendkeys fail etc.
>
> Jesse
>
I wouldn't try to automate by using send keys. I would just use the DOM. For
example, if you navigate to page using internetexplorer.application and
there is a form called "login" woith two textboxes called "username" and
"pword" then:
Dim oIE
Set oIE = CreateObject("InternetExplorer.Application")
oIE.navigate <url>
oIE.visible = True
Do While oIE.ReadyState <> 4
WScript.sleep 500
Loop
Dim oDoc
Set oDoc = oIE.document
Dim oForm
Set oForm = oDoc.forms("login")
oForm.elements("username").value = "JoeFawcett"
oForm.elements("pword").value = "password"
oForm.submit


An alternative to this is to post the data directly using XmlHttp.4.0.

--

Joe



Re: HTML DOM by Jessard

Jessard
Sun Nov 07 02:07:01 CST 2004

Thanks for you help Joe.

Your last sentence is exactly what I have done now - It's all good. Didn't
want to use InternetExplorer.Application object.

Jesse

"Joe Fawcett" wrote:

> "Jessard" <Jessard@discussions.microsoft.com> wrote in message
> news:43FB7156-1C3D-460C-B45A-EF87686CD429@microsoft.com...
> > Hi, thanks for the reply.
> >
> > Can you explain differences between MICROSOFT.XMLHTTP and
> > msxml2.XmlHttp.4.0.
>
> MICROSOFT.XMLHTTP is an earlier less reliable version, depending on your
> machine version you could get anything from version 2.6 to version 3.
> msxml2.XmlHttp.4.0 is the latest general release.
>
> >Does msxml2.XmlHttp.4.0 parse also? What happens when I
> > navigate to a URL which is for a file and not a HTML page?
> >
> No, it can fetch "any" http resource.
>
> > I am trying to somehow assign values to textboxes and click a button. But
> > the end result requires downloading files (that are not HTML documents).
> >
> > When i use the IeApp object there are issues when there is already another
> > browser window open. If a browser window is open and i run a vbscript to
> do
> > my task it simply flashes down in the taskbar and sendkeys fail etc.
> >
> > Jesse
> >
> I wouldn't try to automate by using send keys. I would just use the DOM. For
> example, if you navigate to page using internetexplorer.application and
> there is a form called "login" woith two textboxes called "username" and
> "pword" then:
> Dim oIE
> Set oIE = CreateObject("InternetExplorer.Application")
> oIE.navigate <url>
> oIE.visible = True
> Do While oIE.ReadyState <> 4
> WScript.sleep 500
> Loop
> Dim oDoc
> Set oDoc = oIE.document
> Dim oForm
> Set oForm = oDoc.forms("login")
> oForm.elements("username").value = "JoeFawcett"
> oForm.elements("pword").value = "password"
> oForm.submit
>
>
> An alternative to this is to post the data directly using XmlHttp.4.0.
>
> --
>
> Joe
>
>
>

Re: HTML DOM by Jessard

Jessard
Sun Nov 07 17:20:02 CST 2004

Sorry, one other question.

If the files that I am downloading are not simple text files how do I
download them using the msxml2.XmlHttp.4.0 object?

Jesse

"Joe Fawcett" wrote:

> "Jessard" <Jessard@discussions.microsoft.com> wrote in message
> news:43FB7156-1C3D-460C-B45A-EF87686CD429@microsoft.com...
> > Hi, thanks for the reply.
> >
> > Can you explain differences between MICROSOFT.XMLHTTP and
> > msxml2.XmlHttp.4.0.
>
> MICROSOFT.XMLHTTP is an earlier less reliable version, depending on your
> machine version you could get anything from version 2.6 to version 3.
> msxml2.XmlHttp.4.0 is the latest general release.
>
> >Does msxml2.XmlHttp.4.0 parse also? What happens when I
> > navigate to a URL which is for a file and not a HTML page?
> >
> No, it can fetch "any" http resource.
>
> > I am trying to somehow assign values to textboxes and click a button. But
> > the end result requires downloading files (that are not HTML documents).
> >
> > When i use the IeApp object there are issues when there is already another
> > browser window open. If a browser window is open and i run a vbscript to
> do
> > my task it simply flashes down in the taskbar and sendkeys fail etc.
> >
> > Jesse
> >
> I wouldn't try to automate by using send keys. I would just use the DOM. For
> example, if you navigate to page using internetexplorer.application and
> there is a form called "login" woith two textboxes called "username" and
> "pword" then:
> Dim oIE
> Set oIE = CreateObject("InternetExplorer.Application")
> oIE.navigate <url>
> oIE.visible = True
> Do While oIE.ReadyState <> 4
> WScript.sleep 500
> Loop
> Dim oDoc
> Set oDoc = oIE.document
> Dim oForm
> Set oForm = oDoc.forms("login")
> oForm.elements("username").value = "JoeFawcett"
> oForm.elements("pword").value = "password"
> oForm.submit
>
>
> An alternative to this is to post the data directly using XmlHttp.4.0.
>
> --
>
> Joe
>
>
>

Re: HTML DOM by Joe

Joe
Tue Nov 09 05:28:46 CST 2004

"Jessard" <Jessard@discussions.microsoft.com> wrote in message
news:AB101B99-9264-4CB6-98C9-C73BF172E137@microsoft.com...
> Sorry, one other question.
>
> If the files that I am downloading are not simple text files how do I
> download them using the msxml2.XmlHttp.4.0 object?
>
> Jesse
>
Public Sub SaveRemoteFile(From, ToPath)
Dim oXmlHttp
Set oXmlHttp = CreateObject("Msxml2.XmlHttp.4.0")
oXmlHttp.Open "GET", From, False
oXmlHttp.Send
If oXmlHttp.Status = 200 Then
Dim oStream
Set oStream = CreateObject("Adodb.Stream")
oStream.Type = 1
oStream.Open
oStream.Write oXmlHttp.responseBody
oStream.SaveToFile ToPath, 2 'Not sure how to specify 1 + 2 in VBS
oStream.Close
Else
Err.Raise vbObjectError + 1, "SaveRemoteFile", oXmlHttp.statusText
End If
End Sub

See:

http://groups.google.com/groups?hl=en&lr=&newwindow=1&threadm=uFp1kuOuEHA.3200%40TK2MSFTNGP14.phx.gbl&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26newwindow%3D1%26as_drrb%3Db%26q%3Dmsxml2.xmlhttp.4.0%2Bauthor%253A%2522Joe%2BFawcett%2522%26btnG%3DSearch%26as_mind%3D12%26as_minm%3D5%26as_miny%3D2004%26as_maxd%3D9%26as_maxm%3D11%26as_maxy%3D2004

--

Joe (MVP - XML)