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="#FFFFFF">
<%
' Name of the access db being queried
accessdb="state_info"
' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
' Query the states table from the state_info db
sql = "select state,statename,capital,year,order from states "
' 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 "do while not rs.eof" 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("state"
& ".doc"
' create a file system object
set fso = createobject("scripting.filesystemobject"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
' 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("<html><title>CodeAve.com(" & rs("statename"
& " State Info)</title>"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
act.WriteLine("<body bgcolor='#FFFFFF'> " )
act.WriteLine("State: " & rs("statename"
& "<br>" )
act.WriteLine("Abbreviaton: " & rs("state"
& "<br>" )
act.WriteLine("Capital: " & rs("capital"
& "<br>"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
act.WriteLine("Entered the Union in "& rs("year"
& "<br>"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
act.WriteLine("Number in order of entrance into the Union "& rs("order"
& "<br>"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
act.WriteLine("Page created on: " & now ())
act.WriteLine("</body></html>"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
' close the object
act.close
' Writes the links to the newly created pages in the browser
response.write "<a href='" & rs("state"
& ".doc'>" & rs("statename"
& "</a> (.doc) " & now() & "<br>"
' move to the next record
rs.movenext
' return to the top of the for - next loop
' change this to "loop" to output all the records
' and the corresponsding for statement above should be changed also
next
%>
</body>
</html>
<html>
<title>CodeAve.com(Create Word on Server)</title>
<body bgcolor="#FFFFFF">
<%
' Name of the access db being queried
accessdb="state_info"
' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset"
' Query the states table from the state_info db
sql = "select state,statename,capital,year,order from states "
' 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 "do while not rs.eof" 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("state"
' create a file system object
set fso = createobject("scripting.filesystemobject"
' 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("<html><title>CodeAve.com(" & rs("statename"
act.WriteLine("<body bgcolor='#FFFFFF'> " )
act.WriteLine("State: " & rs("statename"
act.WriteLine("Abbreviaton: " & rs("state"
act.WriteLine("Capital: " & rs("capital"
act.WriteLine("Entered the Union in "& rs("year"
act.WriteLine("Number in order of entrance into the Union "& rs("order"
act.WriteLine("Page created on: " & now ())
act.WriteLine("</body></html>"
' close the object
act.close
' Writes the links to the newly created pages in the browser
response.write "<a href='" & rs("state"
' move to the next record
rs.movenext
' return to the top of the for - next loop
' change this to "loop" to output all the records
' and the corresponsding for statement above should be changed also
next
%>
</body>
</html>