Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Urgent-writing an HTML file using the FSO
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Urgent-writing an HTML file using the FSO

 Post Reply Post Reply
Author
justinp View Drop Down
Newbie
Newbie
Avatar

Joined: 04 February 2003
Location: United Kingdom
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote justinp Quote  Post ReplyReply Direct Link To This Post Topic: Urgent-writing an HTML file using the FSO
    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"
               
                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">
<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: repeat-x;}
  .whiteTitleText{color:#FFFFFF;font-size:11px;}
 </style>
 <link rel="STYLESHEET" type="text/css" href="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" 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">
       <div><img src=" 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" 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"

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
justinp View Drop Down
Newbie
Newbie
Avatar

Joined: 04 February 2003
Location: United Kingdom
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote justinp Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.