|
-
Aug 10th, 2005, 07:39 PM
#1
Thread Starter
Addicted Member
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)
-
Aug 10th, 2005, 07:43 PM
#2
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.
-
Aug 10th, 2005, 08:16 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|