Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi guys, got this script from codea 1

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hi guys, got this script from codeave.com, but can't get it to work on my computer.. keeps generating an error at the set fso = createobject("scripting.filesystemobject") can anyone help get this working? thanks in advance.


<html>
<title>CodeAve.com(Create Word on Server)</title>
<body bgcolor=&quot;#FFFFFF&quot;>
<%
' Name of the access db being queried
accessdb=&quot;state_info&quot;

' Connection string to the access db
cn=&quot;DRIVER={Microsoft Access Driver (*.mdb)};&quot;
cn=cn & &quot;DBQ=&quot; & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

' Query the states table from the state_info db
sql = &quot;select state,statename,capital,year,order from states &quot;

' Execute the sql
rs.Open sql, cn

' Move to the first record
rs.MoveFirst

' For net loop to create seven word documents from the record set
' change this to &quot;do while not rs.eof&quot; to output all the records
' and the corresponsding next should be changed to loop also

for documents= 1 to 7
' Creates a text file on the server with the state abbreviation
' as the name for the ouput document
file_being_created= rs(&quot;state&quot;) & &quot;.doc&quot;

' create a file system object
set fso = createobject(&quot;scripting.filesystemobject&quot;)

' create the text file - true will overwrite any previous files
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)

' Writes the db output to a .doc file in the same directory
act.WriteLine(&quot;<html><title>CodeAve.com(&quot; & rs(&quot;statename&quot;) & &quot; State Info)</title>&quot;)
act.WriteLine(&quot;<body bgcolor='#FFFFFF'> &quot; )
act.WriteLine(&quot;State: &quot; & rs(&quot;statename&quot;) & &quot;<br>&quot; )
act.WriteLine(&quot;Abbreviaton: &quot; & rs(&quot;state&quot;) & &quot;<br>&quot; )
act.WriteLine(&quot;Capital: &quot; & rs(&quot;capital&quot;) & &quot;<br>&quot;)
act.WriteLine(&quot;Entered the Union in &quot;& rs(&quot;year&quot;) & &quot;<br>&quot;)
act.WriteLine(&quot;Number in order of entrance into the Union &quot;& rs(&quot;order&quot;) & &quot;<br>&quot;)
act.WriteLine(&quot;Page created on: &quot; & now ())
act.WriteLine(&quot;</body></html>&quot;)

' close the object
act.close

' Writes the links to the newly created pages in the browser
response.write &quot;<a href='&quot; & rs(&quot;state&quot;) & &quot;.doc'>&quot; & rs(&quot;statename&quot;) & &quot;</a> (.doc) &nbsp;&quot; & now() & &quot;<br>&quot;

' move to the next record
rs.movenext

' return to the top of the for - next loop
' change this to &quot;loop&quot; to output all the records
' and the corresponsding for statement above should be changed also
next
%>
</body>
</html>
 
should be:

' create a file system object
set fso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
 
Thanks again lobstah... I had to reinstall IIS, it works now.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top