Creating an HTML file

Discussion in 'ASP General' started by J-P-W, May 26, 2009.

  1. J-P-W

    J-P-W Guest

    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-P-W, May 26, 2009
    #1
    1. Advertising

  2. J-P-W

    J-P-W Guest

    On 26 May, 17:51, J-P-W <> wrote:
    > 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!
     
    J-P-W, May 27, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dhanasankar S via DotNetMonster.com

    How to read the BODY of HTML file from another HTML file using javascript?

    Dhanasankar S via DotNetMonster.com, Feb 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    505
    =?Utf-8?B?dHBlcnJp?=
    Feb 28, 2005
  2. Cloud Burst
    Replies:
    11
    Views:
    1,126
  3. Replies:
    3
    Views:
    12,299
    Beauregard T. Shagnasty
    Jan 10, 2006
  4. Tom
    Replies:
    8
    Views:
    733
    Adrienne Boswell
    Feb 13, 2007
  5. Ellie
    Replies:
    1
    Views:
    211
    Bob Barrows [MVP]
    Aug 2, 2008
Loading...

Share This Page