<%@ Language = VBScript %> <% Option Explicit %><% Response.Buffer = True Dim sRTF, sFileName, sConn sConn = Server.MapPath("filnavn.mdb") 'Create the file for the RTF Dim fso, MyFile Set fso = Server.CreateObject("Scripting.FileSystemObject") sFileName = "imagetest.doc" ' Slet output-fil på server, hvis den eksisterer i forvejen If (fso.FileExists(sFileName)) Then fso.DeleteFile(sFileName) End If Set MyFile = fso.CreateTextFile(Server.MapPath(".") & "\" & _ sFileName, True) MyFile.WriteLine("{\rtf1") 'Write the font table sRTF = "{\fonttbl {\f0\froman\fcharset0 Times New Roman;}" & _ "{\f1\fswiss\fcharset0 Arial;}" & _ "{\f2\fmodern\fcharset0 Courier New;}}" MyFile.WriteLine sRTF 'Write the color table (for use in background and foreground colors) sRTF = "{\colortbl;\red0\green0\blue0;\red0\green0\blue255;" & _ "\red0\green255\blue255;\red0\green255\blue0;" & _ "\red255\green0\blue255;\red255\green0\blue0;" & _ "\red255\green255\blue0;\red255\green255\blue255;}" MyFile.WriteLine(sRTF) 'Write the title and author for the document properties MyFile.WriteLine("{\info{\title Fagforbund i Danmark (2006)}" & _ "{\author Jørn Andersen}}") 'Write the page header and footer MyFile.WriteLine("{\header\pard\qc{ ") ' Indsæt billede i header Dim strMyJpeg strMyJpeg = Server.MapPath(".") & "\test6.jpg" fktJpegTilRtf(strMyJpeg) ' Fortsæt header/footer MyFile.WriteLine("\fs20 Fagforbund i Danmark (2006) v. Jørn Andersen\par}{\fs18\chdate\par}\par\par}") MyFile.WriteLine("{\footer\pard\qr\brdrt\brdrs\brdrw10\brsp100" & _ "\fs18 Side " & _ "{\field{\*\fldinst PAGE}{\fldrslt 1}} af " & _ "{\field{\*\fldinst NUMPAGES}{\fldrslt 1}} \par}") 'Write a sentence in the first paragraph of the document MyFile.WriteLine("\par\fs50\cf2\b Fagforbund i Danmark \b0\cf0") ' Indsæt billede i overskrift strMyJpeg = Server.MapPath(".") & "\marx2.jpg" fktJpegTilRtf(strMyJpeg) 'Connect to the database in read-only mode Dim conn, rs Set conn = Server.CreateObject("ADODB.Connection") Conn.Provider = "Microsoft.Jet.OLEDB.4.0" conn.Mode = 1 'adModeRead=1 conn.Open sConn 'Execute a query that returns ID, Product name and amount of sale Set rs = Server.CreateObject("ADODB.Recordset") Dim strSql strSql = "SELECT Id, FagfNavn, FagfWww FROM tblTabel" rs.Open strSql, conn, 3 MyFile.WriteLine("{") 'Start table MyFile.WriteLine("\par\par\fs24") 'Write the table header row (appears at top of table on each page) sRTF = "\trowd\trhdr\trgaph30\trleft0\trrh262" & _ "\cellx500\cellx5000\cellx9000" & _ "\pard\intbl\qr\b\i\ul ID \ul0\i0\b0\par\cell" & _ "\pard\intbl\ql\b\i\cf6\cb2\ul Forbund \cb0\ul0\i0\b0\par\cell" & _ "\pard\intbl\ql\ul\b\cf3\i Webadresse \cf0\ul0\i0\b0\par\cell" & _ "\pard\intbl\row" MyFile.WriteLine(sRTF) Do While Not (rs.eof) 'Add a new row with the ID, the Product name and the amount sRTF = "\trowd\trgaph30\trleft0\trrh262" & _ "\cellx500\cellx5000\cellx9000" & _ "\f1\pard\intbl\qr " & rs(0) & "\f0\cell" & _ "\f0\pard\intbl\ql\cf6 " & rs(1) & "\f0\cf0\cell" & _ "\f2\pard\intbl\ql\cf3 " & rs(2) & "\f0\cf0\cell\pard\intbl\row" MyFile.WriteLine(sRTF) rs.MoveNext Loop MyFile.WriteLine("}") 'End Table 'Add a page break and then a new paragraph ' MyFile.WriteLine("\par \page") ' MyFile.WriteLine("\pard\fs18\cf2\qc " & _ ' "This sample provided by Microsoft Developer Support.") 'Close the RTF string and file MyFile.WriteLine("}") MyFile.Close Response.Write _ "" %>