Results 1 to 3 of 3

Thread: save frames inside HTMLDocument to local location

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160

    save frames inside HTMLDocument to local location

    hi guys
    I'm trying to save an html file into local path, but I have trouble with saving frames, below is my current code for this part.

    thanks

    Code:
    Dim objImg As IHTMLImgElement               'object holder for html images
    Dim objHypLink As MSHTML.HTMLLinkElement    'object holder for html hyperlink
    Dim objMSHTML As New MSHTML.HTMLDocument    'main html creator using CreateDocument
    Dim objDoc As HTMLDocument                  'main holder for html document
    Dim vFileName, vPath                        'temporary filename for images and html to download and send /
                                                'filepath holder for eath file
    Dim objFrm As IHTMLElementCollection        'object holder for frames inside html document
    Dim defPath 'Default Path                   'default saving path
    
    Dim vTemp                                   'temporary holder for status message
    defPath = "C:\Temp\"
    
    'load page
    Set objDoc = objMSHTML.createDocumentFromUrl(txtAddress, vbNullString)
    
    'wait for loading
    
    AddStat "Start Loading webpage..."
    Do While objDoc.ReadyState <> "complete"
        If vTemp <> objDoc.ReadyState Then
            AddStat objDoc.ReadyState
        End If
        vTemp = objDoc.ReadyState
        DoEvents
    Loop
    AddStat "Loading completed."
    
    Dim vFile(), I  'html filenames and paths
    
    'insert frame to main html
    MsgBox objDoc.frames.length
    ReDim vFile(0 To objDoc.frames.length + objDoc.images.length)
    For I = 0 To objDoc.frames.length - 1
        Dim eCollection As IHTMLElementCollection
        Set eCollection = objDoc.frames(I).Document.All
        MsgBox objDoc.frames(I).Document.All
        vFile(I) = defPath & Replace(Mid(objFrm.src, Len(objDoc.location) + 1), "/", "\")
        vPath = Mid(vFile(I), InStrRev(vFile(I), "\") + 1)
        rMkDir Mid(vFile(I), 1, InStrRev(vFile(I), "\"))
        URLDownloadToFile 0&, objFrm.src, vFile(I), 0&, 0&
    Next I

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: save frames inside HTMLDocument to local location

    Are you getting error messages or is just nothing happening?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160

    Re: save frames inside HTMLDocument to local location

    I get error at set ecollection line

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width