Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

!!!!Saving a html page from IE.document!!!!

Status
Not open for further replies.

cucswiz

Programmer
Jun 25, 2001
13
US
I am trying to save whatever is being currently displayed on my InternetExplorer component. I have tried to use ie.document.All.toString - however this seems to only output [object].... I am not very fluent in VB as in I have only used it for about 1 day. But from my java experience, isn't .toString supposed to give me back a string..?? Locially a string that represents the html page that I am trying to save?? Please any help on this would be helpful... Thanks

 
This works in WebBrowser.
Code:
'.getElementsByTagName returns a collection like object.
    dim strText As String
    Dim objElements As Object
    Set objElements = WebBrowser1.Document.getElementsByTagName("HTML")
    if objelements.Length > 0 then
        strText = objElements(0).outerHTML
    end if
 
Thanks for the response. I actually figured it out as well. However, to make this more robust, when getting the element name (i.e. "html" or "HTML") does capitalization matter?? I.E. When I say getElementByName("html") vs. ("HTML") will these return the same things??

 
I'm not sure on getElementByTagName. Try it.
When I have to go through an .ALL &quot;collection&quot; looking for <A> that do not have a NAME or ID I do use
if lcase(objElement.TagName) = &quot;a&quot;

This is a helpful link for W3C DHTML. I always use AS OBJECT to access the element(s).
 
JohnYingling... Just a really basic question. Say I am looking for a tag (i.e. &quot;form&quot;)

Thus I do something like this:

Dim htmlElmt As HTMLGenericElement
Set doc As InternetExplorer.document

For Each htmlElmt In doc.All.tag(&quot;form&quot;)
...

How do I check if there are no &quot;form&quot; tags on my page?? I have tried to do something like this:

If doc.All.tag(&quot;form&quot; = Null Then
...

But that give me a type error. Any ideas? I just basically want to say: If there are forms on the html page, go into the loop, if there are no tags, then do something else.

Thanks again for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top