Creating an HTML file

J

J-P-W

Hi,

Using the code below I'm grabbing an ASP page, getting the HTML as a
string. Then I'm trying to save that as an HTML file. If I allow
"strResult = "A line of text" to be there then the small file is
created and written to. If I allow the full HTML to be the string I
get "Microsoft VBScript runtime (0x800A0005) - Invalid procedure call
or argument.

I've looked for limiations of the WriteLine side of things (where the
error is) but can't see any.

Perhaps it's a character that is causing it?

Can anyone advise on how to get around this please?

Thank you

Jon

<%
Function WriteLineToFile(theString, TheFileNameAndPath)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(TheFileNameAndPath, 2, True)
f.WriteLine theString
End Function


Dim objXML
Dim strResult
set objXML = Server.CreateObject ("MSXML2.ServerXMLHTTP")
objXML.Open "GET", "http://localhost/.....page.asp"
objXML.Send
strResult = objXML.responsetext
set xmlhttp = nothing
Set objXML = nothing

strResult = replace(strResult,vbcrlf,"")
strResult = replace(strResult,vbtab,"")
' strResult = "A line of text"
FileNameAndPath = "....full path here....\test3.htm"
Call WriteLineToFile(strResult, FileNameAndPath)
%>
 
J

J-P-W

Hi,

Using the code below I'm grabbing an ASP page, getting the HTML as a
string. Then I'm trying to save that as an HTML file. If I allow
"strResult = "A line of text" to be there then the small file is
created and written to. If I allow the full HTML to be the string I
get "Microsoft VBScript runtime (0x800A0005) - Invalid procedure call
or argument.

I've looked for limiations of the WriteLine side of things (where the
error is) but can't see any.

Perhaps it's a character that is causing it?

Can anyone advise on how to get around this please?

Thank you

Jon

<%
Function WriteLineToFile(theString, TheFileNameAndPath)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso_OpenTextFile(TheFileNameAndPath, 2, True)
   f.WriteLine theString
End Function

    Dim objXML
    Dim strResult
    set objXML = Server.CreateObject ("MSXML2.ServerXMLHTTP")
    objXML.Open "GET", "http://localhost/.....page.asp"
    objXML.Send
    strResult = objXML.responsetext
    set xmlhttp = nothing
    Set objXML = nothing

        strResult = replace(strResult,vbcrlf,"")
        strResult = replace(strResult,vbtab,"")
'       strResult = "A line of text"
        FileNameAndPath = "....full path here....\test3.htm"
        Call WriteLineToFile(strResult, FileNameAndPath)
%>

All sorted, using a different method:

<%@ CodePage=28592 Language="VBScript"%>
<%
Function DeleteIt(TheFileName)
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
filesys.CreateTextFile TheFileName, True
If filesys.FileExists(TheFileName) Then
filesys.DeleteFile TheFileName
'file deleted
End If
set filesys=nothing

End Function

Function SaveTheFile(TheFileName, URL)
Set Http = CreateObject("Microsoft.XMLHTTP")

Http.Open "GET", URL, False
Http.Send

GetURL = Http.ResponseText

Call DeleteIt(TheFileName)

Set fstemp = server.CreateObject("Scripting.FileSystemObject")
Set filetemp = fstemp.CreateTextFile(TheFileName, fsoForWriting,
true)

filetemp.Write GetURL
filetemp.Close

set filetemp=nothing
set fstemp=nothing

End Function


URL = "http://.......asp"
TheFileName = "c:\.........\........\.....test4.htm"
Call SaveTheFile(TheFileName, URL)
%>

Hope you find this useful!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top