Results 1 to 3 of 3

Thread: insert frame html into HTMLdocument

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160

    insert frame html into HTMLdocument

    hi guys
    I've made a function to save and email a webpage, however in case there is a frame like this:

    Code:
    <frame src="Pan%20Iranisim%20%20%20One%20United%20Iranian%20Nation_files/pan1.htm" frameborder="no" border="0" noresize="noresize" scrolling="auto">
    I dont want save a secondary file and I want to insert it into my main html and all images inside that...

    how to do that?

    thanks

    here is the part of my code:

    Code:
    Dim objImg As IHTMLImgElement
    Dim objHypLink As MSHTML.HTMLLinkElement
    Dim objMSHTML As New MSHTML.HTMLDocument
    Dim objDoc As HTMLDocument, vFileName, vPath
    
    Dim defPath 'Default Path
    
    defPath = "C:\Temp\"
    'load page
    Set objDoc = objMSHTML.createDocumentFromUrl(txtAddress, vbNullString)
    
    'wait for loading
    Dim vTemp
    AddStat "Start Loading webpage..."
    Do While objDoc.ReadyState <> "complete"
    
        If vTemp <> objDoc.ReadyState Then
            AddStat objDoc.ReadyState
        End If
        vTemp = objDoc.ReadyState
        DoEvents
    
    Loop
    
    Dim vFile(), I
    'Exit Sub
    'save images
    
    ReDim vFile(0 To objDoc.images.length)
    AddStat "Start saving " & objDoc.images.length & " images."
    For Each objImg In objDoc.images
        
        vFile(I) = defPath & Replace(Mid(objImg.src, Len(objDoc.location) + 1), "/", "\")
        vPath = Mid(vFile(I), InStrRev(vFile(I), "\") + 1)
        rMkDir Mid(vFile(I), 1, InStrRev(vFile(I), "\"))
        URLDownloadToFile 0&, objImg.src, vFile(I), 0&, 0&
        'MsgBox objImg.src
    
        'MsgBox objImg.src
        I = I + 1
    Next objImg
    
    AddStat "Saving " & objDoc.images.length & " images finished."
    
    I = 0
    
    'insert frame to main html
    
    'save href for each hyperlink
    Dim oLink
    Do
        Set oLink = objDoc.getElementsByTagName("A")(I)
        If oLink Is Nothing Then Exit Do
        oLink.setAttribute "href", objDoc.links(I) '<-- Replace with your link page
        I = I + 1
    Loop
    AddStat "absoluting href"
    
    
    'create appropriate name for html file
    
    If Right(txtAddress.Text, 1) = "/" Then
        txtAddress.Text = Mid(txtAddress.Text, 1, Len(txtAddress.Text) - 1)
    End If
    
    If InStrRev(Mid(txtAddress.Text, 8), "/") = 0 Then
        vFileName = "C:\temp\index.html"
    Else
        vStart = InStrRev(Mid(txtAddress.Text, 8), "/") + 8
        vFileName = Mid(txtAddress.Text, vStart)
        vFileName = "C:\temp\" & vFileName
        If LCase(Right(vFileName, 5)) <> ".html" And Left(Right(vFileName, 4), 1) <> "." Then
            vFileName = vFileName & ".htm"
        End If
    End If
    
    
    
    ' Save source into html file
    Dim vText, chText
    vText = objDoc.documentElement.outerHTML
    Text1.Text = vText
    ReDim chText(0 To Len(vText))
    AddStat "converting unicode to $#1740;"
    
    For I = 0 To Len(vText) - 1
        chText(I) = Mid(vText, I + 1, 1)
        'MsgBox AscW(Mid(vText, I + 1, 1))
        If AscW(chText(I)) > 255 Then
            chText(I) = "&#" & AscW(chText(I)) & ";"
        End If
        DoEvents
    Next I
    
    
    vText = Join(chText, "")
    Call CreateFile(vFileName, vText)

  2. #2
    No place like 127.0.0.1 eyeRmonkey's Avatar
    Join Date
    Jul 2005
    Location
    Blissful Oblivion
    Posts
    2,306

    Re: insert frame html into HTMLdocument

    Unless I understood you wrong, then what you are asking is impossible. You to have a frameset you need 3 or more files. 1 to hold the frameset, and 1 for each frame in the frameset.
    Visual Studio 2005 Professional Edition (.NET Framework 2.0)
    ~ VB .NET Links: Visual Basic 6 to .NET Function Equivalents (Thread) | Refactor! (White Paper) | Easy Control for Wizard Forms | Making A Proper UI For WinForms | Graphics & GDI+ Tutorial | Websites For Free Icons
    ~ QUOTE: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -Rich Cook

    ~ eyeRmonkey.com

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160

    Re: insert frame html into HTMLdocument

    ok, how do I load all frame to save?
    is it possible to send html-email with frame?

    I tried this but I get this error"Object doesn't support this propertyor method at FOR NEXT line:

    Code:
    Dim objDoc As HTMLDocument, vFileName, vPath
    Dim objFrm As IHTMLFrameElement
    
    Set objDoc = objMSHTML.createDocumentFromUrl(txtAddress, vbNullString)
    
    Dim vTemp
    AddStat "Start Loading webpage..."
    Do While objDoc.ReadyState <> "complete"
    
        If vTemp <> objDoc.ReadyState Then
            AddStat objDoc.ReadyState
        End If
        vTemp = objDoc.ReadyState
        DoEvents
    
    Loop
    Dim vFile(), I
    
    For Each objFrm In objDoc.frames
        
        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&
        'MsgBox objImg.src
    
        'MsgBox objImg.src
        I = I + 1
    Next objFrm

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