Print Page | Close Window

Urgent-writing an HTML file using the FSO

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8211
Printed Date: 01 April 2026 at 1:00am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Urgent-writing an HTML file using the FSO
Posted By: justinp
Subject: Urgent-writing an HTML file using the FSO
Date Posted: 19 December 2003 at 4:55am

Hi,

I'm using this code below to grab the HTML output of an ASP(template) page and then write it to a static HTML file. The content will print to a page fine using a response.write, but when it goes to write to a file, for some reason I get this error:
Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

/refresh_admin/adminEditNewsletterContentPopup.asp, line 95

Line 95 is this one:
lStrFileCreate.WriteLine(lStrContent)

If I change the line to: lStrFileCreate.WriteLine("Some Text")  , it works fine

My CODE:


strURL = " http://localhost:90/refresh_admin/adminPreviewNewsletter.asp?id=9 - http://localhost:90/refresh_admin/adminPreviewNewsletter.asp ?id=9 "
               
                Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
                objXMLHTTP.Open "GET", strURL, false
                objXMLHTTP.Send
               
                lStrContent =  objXMLHTTP.responseText
               
                Set objXMLHTTP = Nothing

                lStrPath = Server.MapPath("\newsletter") & "\"
                lStrFileName = replace(date,"/","_") & "_newsletter.html"

                Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
               
                                 Set lStrFileCreate = objFSO.CreateTextFile(lStrPath & lStrFileName, true)
                     lStrFileCreate.WriteLine(lStrContent)
                     lStrFileCreate.Close
               
                Set objFSO = Nothing

I've been trying to sort this for the last two days but I'm at my wits end. I'm pretty sure it's the contents of my outputted template page that is causing this as I've tried it with a simple template and it works ok.

This is the source code that is spat out by ASP and is what I want to write to the HTML file:

<!-- BEGIN NEWSLETTER -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
" http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd - http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd ">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <meta name="MSSmartTagsPreventParsing" content="TRUE">
 <meta http-equiv="Description" content="">
 <title></title>
 <style>
  .bgTop{background-color:#FFFFFF;background-image : url( http://localhost:90/newsletter/images/newsletter_bg_top.gif;background-repeat - http://localhost:90/newsletter/images/newsletter_bg_top.gif) ;background-repeat : repeat-x;}
  .whiteTitleText{color:#FFFFFF;font-size:11px;}
 </style>
 <link rel="STYLESHEET" type="text/css" href=" http://localhost:90/resources/refresh_corp_styles.css - http://localhost:90/resources/refresh_corp_styles.css ">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 <table cellpadding="0" cellspacing="0" border="0" width="520" height="100%" align="center">
  <tr>
   <td width="15" class="bgTop"></td>
   <td width="490" class="bgTop" valign="top">   
    <table cellpadding="0" cellspacing="0" border="0" width="490">
     <tr>
      <td rowspan="2"><a href="/"><img src=" http://localhost:90/newsletter/images/newsletter_logo.gif - http://localhost:90/newsletter/images/newsletter_logo.gif " alt="Homepage" width="230" height="96" border="0"></a></td>
      <td width="100%" valign="middle" align="right" background=" http://localhost:90/images/images/default/bg_top.gif - http://localhost:90/images/images/default/bg_top.gif ">
       <div><img src=" http://localhost:90/newsletter/images/newsletter_phone_number.gif - http://localhost:90/newsletter/images/newsletter_phone_numbe r.gif " alt="" width="203" height="37" border="0"></div>
       <div class="arial11Grey">Date: 19/12/2003</div></td>
     </tr>
    </table>
    <table cellpadding="0" cellspacing="0" border="0" width="490">
     <tr>
      <td width="25" height="25"><img src=" http://localhost:90/newsletter/images/title_icon_grey.gif - http://localhost:90/newsletter/images/title_icon_grey.gif " alt="" width="25" height="25" border="0"></td>
      <td width="465" bgcolor="#909090" class="whiteTitleText">
       <b>
       A title
       </b></td& gt;
     </tr>
     <tr><td height="1"></td></tr>
    </table>
    <table cellpadding="0" cellspacing="0" border="0" width="490">
     <tr>
      <td colspan="2" class="arial11Grey">
       <div style="padding:5px;">
       And some text....
       </div>
       </td>
     </tr>
     <tr><td bgcolor="#909090" colspan="2" height="4"></td></tr>
     <tr><td height="1"></td></tr>
     <tr>
      <td>

       <table width="490" border="0" cellspacing="0" cellpadding="0" background=" http://localhost:90/images/default/bg_greyfade_main.gif - http://localhost:90/images/default/bg_greyfade_main.gif "




Replies:
Posted By: MorningZ
Date Posted: 19 December 2003 at 5:42am

you checked to make sure that the FSO object worked

lStrFileCreate.WriteLine("Some Text")

But it appears that no where did you make sure that

lStrContent =  objXMLHTTP.responseText

Returned any results,  like doing Response.Write( lStrContent )



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: justinp
Date Posted: 19 December 2003 at 5:44am

Thanks for your response.

It definitely does return results. During testing I've been using response.write to write the HTML to the page each time. I took it out of the code above to post.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net